LCOV - code coverage report
Current view: top level - gcc - tree.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 85.1 % 7150 6087
Test Date: 2026-11-14 16:39:50 Functions: 90.1 % 466 420
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 "rtl.h"
      68              : #include "regs.h"
      69              : #include "tree-vector-builder.h"
      70              : #include "gimple-fold.h"
      71              : #include "escaped_string.h"
      72              : #include "gimple-range.h"
      73              : #include "gomp-constants.h"
      74              : #include "dfp.h"
      75              : #include "asan.h"
      76              : #include "ubsan.h"
      77              : #include "attr-callback.h"
      78              : 
      79              : /* For qualifier_set::{join,merge}.  */
      80              : #include "stdbackport/expected"
      81              : 
      82              : /* Names of tree components.
      83              :    Used for printing out the tree and error messages.  */
      84              : #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
      85              : #define END_OF_BASE_TREE_CODES "@dummy",
      86              : 
      87              : static const char *const tree_code_name[] = {
      88              : #include "all-tree.def"
      89              : };
      90              : 
      91              : #undef DEFTREECODE
      92              : #undef END_OF_BASE_TREE_CODES
      93              : 
      94              : /* Each tree code class has an associated string representation.
      95              :    These must correspond to the tree_code_class entries.  */
      96              : 
      97              : const char *const tree_code_class_strings[] =
      98              : {
      99              :   "exceptional",
     100              :   "constant",
     101              :   "type",
     102              :   "declaration",
     103              :   "reference",
     104              :   "comparison",
     105              :   "unary",
     106              :   "binary",
     107              :   "statement",
     108              :   "vl_exp",
     109              :   "expression"
     110              : };
     111              : 
     112              : /* obstack.[ch] explicitly declined to prototype this.  */
     113              : extern int _obstack_allocated_p (struct obstack *h, void *obj);
     114              : 
     115              : /* Statistics-gathering stuff.  */
     116              : 
     117              : static uint64_t tree_code_counts[MAX_TREE_CODES];
     118              : uint64_t tree_node_counts[(int) all_kinds];
     119              : uint64_t tree_node_sizes[(int) all_kinds];
     120              : 
     121              : /* Keep in sync with tree.h:enum tree_node_kind.  */
     122              : static const char * const tree_node_kind_names[] = {
     123              :   "decls",
     124              :   "types",
     125              :   "blocks",
     126              :   "stmts",
     127              :   "refs",
     128              :   "exprs",
     129              :   "constants",
     130              :   "identifiers",
     131              :   "vecs",
     132              :   "binfos",
     133              :   "ssa names",
     134              :   "constructors",
     135              :   "random kinds",
     136              :   "lang_decl kinds",
     137              :   "lang_type kinds",
     138              :   "omp clauses",
     139              : };
     140              : 
     141              : /* Unique id for next decl created.  */
     142              : static GTY(()) int next_decl_uid;
     143              : /* Unique id for next type created.  */
     144              : static GTY(()) unsigned next_type_uid = 1;
     145              : /* Unique id for next debug decl created.  Use negative numbers,
     146              :    to catch erroneous uses.  */
     147              : static GTY(()) int next_debug_decl_uid;
     148              : 
     149              : /* Since we cannot rehash a type after it is in the table, we have to
     150              :    keep the hash code.  */
     151              : 
     152              : struct GTY((for_user)) type_hash {
     153              :   unsigned long hash;
     154              :   tree type;
     155              : };
     156              : 
     157              : /* Initial size of the hash table (rounded to next prime).  */
     158              : #define TYPE_HASH_INITIAL_SIZE 1000
     159              : 
     160              : struct type_cache_hasher : ggc_cache_ptr_hash<type_hash>
     161              : {
     162   8460697798 :   static hashval_t hash (type_hash *t) { return t->hash; }
     163              :   static bool equal (type_hash *a, type_hash *b);
     164              : 
     165              :   static int
     166   2065928436 :   keep_cache_entry (type_hash *&t)
     167              :   {
     168   2065928436 :     return ggc_marked_p (t->type);
     169              :   }
     170              : };
     171              : 
     172              : /* Now here is the hash table.  When recording a type, it is added to
     173              :    the slot whose index is the hash code.  Note that the hash table is
     174              :    used for several kinds of types (function types, array types and
     175              :    array index range types, for now).  While all these live in the
     176              :    same table, they are completely independent, and the hash code is
     177              :    computed differently for each of these.  */
     178              : 
     179              : static GTY ((cache)) hash_table<type_cache_hasher> *type_hash_table;
     180              : 
     181              : /* Hash table and temporary node for larger integer const values.  */
     182              : static GTY (()) tree int_cst_node;
     183              : 
     184              : struct int_cst_hasher : ggc_cache_ptr_hash<tree_node>
     185              : {
     186              :   static hashval_t hash (tree t);
     187              :   static bool equal (tree x, tree y);
     188              : };
     189              : 
     190              : static GTY ((cache)) hash_table<int_cst_hasher> *int_cst_hash_table;
     191              : 
     192              : /* Class and variable for making sure that there is a single POLY_INT_CST
     193              :    for a given value.  */
     194              : struct poly_int_cst_hasher : ggc_cache_ptr_hash<tree_node>
     195              : {
     196              :   typedef std::pair<tree, const poly_wide_int *> compare_type;
     197              :   static hashval_t hash (tree t);
     198              :   static bool equal (tree x, const compare_type &y);
     199              : };
     200              : 
     201              : static GTY ((cache)) hash_table<poly_int_cst_hasher> *poly_int_cst_hash_table;
     202              : 
     203              : /* Hash table for optimization flags and target option flags.  Use the same
     204              :    hash table for both sets of options.  Nodes for building the current
     205              :    optimization and target option nodes.  The assumption is most of the time
     206              :    the options created will already be in the hash table, so we avoid
     207              :    allocating and freeing up a node repeatably.  */
     208              : static GTY (()) tree cl_optimization_node;
     209              : static GTY (()) tree cl_target_option_node;
     210              : 
     211              : struct cl_option_hasher : ggc_cache_ptr_hash<tree_node>
     212              : {
     213              :   static hashval_t hash (tree t);
     214              :   static bool equal (tree x, tree y);
     215              : };
     216              : 
     217              : static GTY ((cache)) hash_table<cl_option_hasher> *cl_option_hash_table;
     218              : 
     219       882669 : struct gt_value_expr_mark_data {
     220              :   hash_set<tree> pset;
     221              :   auto_vec<tree, 16> to_mark;
     222              : };
     223              : 
     224              : /* Callback called through walk_tree_1 to discover DECL_HAS_VALUE_EXPR_P
     225              :    VAR_DECLs which weren't marked yet, in that case marks them and
     226              :    walks their DECL_VALUE_EXPR expressions.  */
     227              : 
     228              : static tree
     229     24383574 : gt_value_expr_mark_2 (tree *tp, int *, void *data)
     230              : {
     231     24383574 :   tree t = *tp;
     232     24383574 :   if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t) && !ggc_marked_p (t))
     233              :     {
     234         1131 :       tree dve = DECL_VALUE_EXPR (t);
     235         1131 :       gt_value_expr_mark_data *d = (gt_value_expr_mark_data *) data;
     236         1131 :       walk_tree_1 (&dve, gt_value_expr_mark_2, data, &d->pset, NULL);
     237         1131 :       d->to_mark.safe_push (t);
     238              :     }
     239     24383574 :   return NULL_TREE;
     240              : }
     241              : 
     242              : /* Callback called through traverse_noresize on the
     243              :    value_expr_for_decl hash table.  */
     244              : 
     245              : int
     246     10353317 : gt_value_expr_mark_1 (tree_decl_map **e, gt_value_expr_mark_data *data)
     247              : {
     248     10353317 :   if (ggc_marked_p ((*e)->base.from))
     249      9041054 :     walk_tree_1 (&(*e)->to, gt_value_expr_mark_2, data, &data->pset, NULL);
     250     10353317 :   return 1;
     251              : }
     252              : 
     253              : /* The value_expr_for_decl hash table can have mappings for trees
     254              :    which are only referenced from mappings of other trees in the
     255              :    same table, see PR118790.  Without this routine, gt_cleare_cache
     256              :    could clear hash table slot of a tree which isn't marked but
     257              :    will be marked when processing later hash table slot of another
     258              :    tree which is marked.  This function marks with the above
     259              :    helpers marks all the not yet marked DECL_HAS_VALUE_EXPR_P
     260              :    VAR_DECLs mentioned in DECL_VALUE_EXPR expressions of marked
     261              :    trees and in that case also recurses on their DECL_VALUE_EXPR.  */
     262              : 
     263              : void
     264       882669 : gt_value_expr_mark (hash_table<tree_decl_map_cache_hasher> *h)
     265              : {
     266       882669 :   if (!h)
     267            0 :     return;
     268              : 
     269       882669 :   gt_value_expr_mark_data data;
     270       882669 :   h->traverse_noresize<gt_value_expr_mark_data *,
     271     11235986 :                        gt_value_expr_mark_1> (&data);
     272      2649138 :   for (auto v : data.to_mark)
     273         1131 :     gt_ggc_mx (v);
     274       882669 : }
     275              : 
     276              : /* General tree->tree mapping  structure for use in hash tables.  */
     277              : 
     278              : 
     279              : static GTY ((cache))
     280              :      hash_table<tree_decl_map_cache_hasher> *debug_expr_for_decl;
     281              : 
     282              : static GTY ((cache ("gt_value_expr_mark")))
     283              :      hash_table<tree_decl_map_cache_hasher> *value_expr_for_decl;
     284              : 
     285              : static GTY ((cache))
     286              :      hash_table<tree_vec_map_cache_hasher> *debug_args_for_decl;
     287              : 
     288              : static void set_type_quals (tree, qualifier_set);
     289              : static void print_type_hash_statistics (void);
     290              : static void print_debug_expr_statistics (void);
     291              : static void print_value_expr_statistics (void);
     292              : 
     293              : tree global_trees[TI_MAX];
     294              : tree integer_types[itk_none];
     295              : 
     296              : bool int_n_enabled_p[NUM_INT_N_ENTS];
     297              : struct int_n_trees_t int_n_trees [NUM_INT_N_ENTS];
     298              : 
     299              : bool tree_contains_struct[MAX_TREE_CODES][64];
     300              : 
     301              : /* Number of operands for each OMP clause.  */
     302              : unsigned const char omp_clause_num_ops[] =
     303              : {
     304              :   0, /* OMP_CLAUSE_ERROR  */
     305              :   1, /* OMP_CLAUSE_PRIVATE  */
     306              :   1, /* OMP_CLAUSE_SHARED  */
     307              :   1, /* OMP_CLAUSE_FIRSTPRIVATE  */
     308              :   2, /* OMP_CLAUSE_LASTPRIVATE  */
     309              :   5, /* OMP_CLAUSE_REDUCTION  */
     310              :   5, /* OMP_CLAUSE_TASK_REDUCTION  */
     311              :   5, /* OMP_CLAUSE_IN_REDUCTION  */
     312              :   1, /* OMP_CLAUSE_COPYIN  */
     313              :   1, /* OMP_CLAUSE_COPYPRIVATE  */
     314              :   3, /* OMP_CLAUSE_LINEAR  */
     315              :   1, /* OMP_CLAUSE_AFFINITY  */
     316              :   2, /* OMP_CLAUSE_ALIGNED  */
     317              :   3, /* OMP_CLAUSE_ALLOCATE  */
     318              :   1, /* OMP_CLAUSE_DEPEND  */
     319              :   1, /* OMP_CLAUSE_NONTEMPORAL  */
     320              :   1, /* OMP_CLAUSE_UNIFORM  */
     321              :   1, /* OMP_CLAUSE_ENTER  */
     322              :   1, /* OMP_CLAUSE_LINK  */
     323              :   1, /* OMP_CLAUSE_LOCAL */
     324              :   1, /* OMP_CLAUSE_DETACH  */
     325              :   1, /* OMP_CLAUSE_USE_DEVICE_PTR  */
     326              :   1, /* OMP_CLAUSE_USE_DEVICE_ADDR  */
     327              :   1, /* OMP_CLAUSE_IS_DEVICE_PTR  */
     328              :   1, /* OMP_CLAUSE_INCLUSIVE  */
     329              :   1, /* OMP_CLAUSE_EXCLUSIVE  */
     330              :   3, /* OMP_CLAUSE_FROM  */
     331              :   3, /* OMP_CLAUSE_TO  */
     332              :   3, /* OMP_CLAUSE_MAP (update walk_tree_1 if this is changed)  */
     333              :   1, /* OMP_CLAUSE_HAS_DEVICE_ADDR  */
     334              :   1, /* OMP_CLAUSE_DOACROSS  */
     335              :   3, /* OMP_CLAUSE__MAPPER_BINDING_  */
     336              :   2, /* OMP_CLAUSE__CACHE_  */
     337              :   1, /* OMP_CLAUSE_DESTROY  */
     338              :   2, /* OMP_CLAUSE_INIT  */
     339              :   1, /* OMP_CLAUSE_USE  */
     340              :   1, /* OMP_CLAUSE_INTEROP  */
     341              :   2, /* OMP_CLAUSE_GANG  */
     342              :   1, /* OMP_CLAUSE_ASYNC  */
     343              :   1, /* OMP_CLAUSE_WAIT  */
     344              :   0, /* OMP_CLAUSE_AUTO  */
     345              :   0, /* OMP_CLAUSE_SEQ  */
     346              :   1, /* OMP_CLAUSE__LOOPTEMP_  */
     347              :   1, /* OMP_CLAUSE__REDUCTEMP_  */
     348              :   1, /* OMP_CLAUSE__CONDTEMP_  */
     349              :   1, /* OMP_CLAUSE__SCANTEMP_  */
     350              :   1, /* OMP_CLAUSE_IF  */
     351              :   1, /* OMP_CLAUSE_SELF */
     352              :   1, /* OMP_CLAUSE_NUM_THREADS  */
     353              :   1, /* OMP_CLAUSE_SCHEDULE  */
     354              :   0, /* OMP_CLAUSE_NOWAIT  */
     355              :   1, /* OMP_CLAUSE_ORDERED  */
     356              :   0, /* OMP_CLAUSE_DEFAULT  */
     357              :   3, /* OMP_CLAUSE_COLLAPSE  */
     358              :   0, /* OMP_CLAUSE_UNTIED   */
     359              :   1, /* OMP_CLAUSE_FINAL  */
     360              :   0, /* OMP_CLAUSE_MERGEABLE  */
     361              :   1, /* OMP_CLAUSE_DEVICE  */
     362              :   1, /* OMP_CLAUSE_DIST_SCHEDULE  */
     363              :   0, /* OMP_CLAUSE_INBRANCH  */
     364              :   0, /* OMP_CLAUSE_NOTINBRANCH  */
     365              :   2, /* OMP_CLAUSE_NUM_TEAMS  */
     366              :   1, /* OMP_CLAUSE_THREAD_LIMIT  */
     367              :   0, /* OMP_CLAUSE_PROC_BIND  */
     368              :   1, /* OMP_CLAUSE_SAFELEN  */
     369              :   3, /* OMP_CLAUSE_SIMDLEN  */
     370              :   0, /* OMP_CLAUSE_DEVICE_TYPE  */
     371              :   0, /* OMP_CLAUSE_FOR  */
     372              :   0, /* OMP_CLAUSE_PARALLEL  */
     373              :   0, /* OMP_CLAUSE_SECTIONS  */
     374              :   0, /* OMP_CLAUSE_TASKGROUP  */
     375              :   1, /* OMP_CLAUSE_PRIORITY  */
     376              :   1, /* OMP_CLAUSE_GRAINSIZE  */
     377              :   1, /* OMP_CLAUSE_NUM_TASKS  */
     378              :   0, /* OMP_CLAUSE_NOGROUP  */
     379              :   0, /* OMP_CLAUSE_THREADS  */
     380              :   0, /* OMP_CLAUSE_SIMD  */
     381              :   1, /* OMP_CLAUSE_HINT  */
     382              :   0, /* OMP_CLAUSE_DEFAULTMAP  */
     383              :   0, /* OMP_CLAUSE_ORDER  */
     384              :   0, /* OMP_CLAUSE_BIND  */
     385              :   1, /* OMP_CLAUSE_FILTER  */
     386              :   1, /* OMP_CLAUSE_INDIRECT  */
     387              :   1, /* OMP_CLAUSE_PARTIAL  */
     388              :   0, /* OMP_CLAUSE_FULL  */
     389              :   1, /* OMP_CLAUSE_SIZES  */
     390              :   1, /* OMP_CLAUSE__SIMDUID_  */
     391              :   0, /* OMP_CLAUSE__SIMT_  */
     392              :   0, /* OMP_CLAUSE_INDEPENDENT  */
     393              :   1, /* OMP_CLAUSE_WORKER  */
     394              :   1, /* OMP_CLAUSE_VECTOR  */
     395              :   1, /* OMP_CLAUSE_NUM_GANGS  */
     396              :   1, /* OMP_CLAUSE_NUM_WORKERS  */
     397              :   1, /* OMP_CLAUSE_VECTOR_LENGTH  */
     398              :   3, /* OMP_CLAUSE_TILE  */
     399              :   0, /* OMP_CLAUSE_IF_PRESENT */
     400              :   0, /* OMP_CLAUSE_FINALIZE */
     401              :   0, /* OMP_CLAUSE_NOHOST */
     402              :   1, /* OMP_CLAUSE_NOVARIANTS */
     403              :   1, /* OMP_CLAUSE_NOCONTEXT */
     404              :   1, /* OMP_CLAUSE_DYN_GROUPPRIVATE  */
     405              :   3, /* OMP_CLAUSE_USES_ALLOCATORS */
     406              :   2, /* OMP_CLAUSE_MESSAGE */
     407              : };
     408              : 
     409              : const char * const omp_clause_code_name[] =
     410              : {
     411              :   "error_clause",
     412              :   "private",
     413              :   "shared",
     414              :   "firstprivate",
     415              :   "lastprivate",
     416              :   "reduction",
     417              :   "task_reduction",
     418              :   "in_reduction",
     419              :   "copyin",
     420              :   "copyprivate",
     421              :   "linear",
     422              :   "affinity",
     423              :   "aligned",
     424              :   "allocate",
     425              :   "depend",
     426              :   "nontemporal",
     427              :   "uniform",
     428              :   "enter",
     429              :   "link",
     430              :   "local",
     431              :   "detach",
     432              :   "use_device_ptr",
     433              :   "use_device_addr",
     434              :   "is_device_ptr",
     435              :   "inclusive",
     436              :   "exclusive",
     437              :   "from",
     438              :   "to",
     439              :   "map",
     440              :   "has_device_addr",
     441              :   "doacross",
     442              :   "_mapper_binding_",
     443              :   "_cache_",
     444              :   "destroy",
     445              :   "init",
     446              :   "use",
     447              :   "interop",
     448              :   "gang",
     449              :   "async",
     450              :   "wait",
     451              :   "auto",
     452              :   "seq",
     453              :   "_looptemp_",
     454              :   "_reductemp_",
     455              :   "_condtemp_",
     456              :   "_scantemp_",
     457              :   "if",
     458              :   "self",
     459              :   "num_threads",
     460              :   "schedule",
     461              :   "nowait",
     462              :   "ordered",
     463              :   "default",
     464              :   "collapse",
     465              :   "untied",
     466              :   "final",
     467              :   "mergeable",
     468              :   "device",
     469              :   "dist_schedule",
     470              :   "inbranch",
     471              :   "notinbranch",
     472              :   "num_teams",
     473              :   "thread_limit",
     474              :   "proc_bind",
     475              :   "safelen",
     476              :   "simdlen",
     477              :   "device_type",
     478              :   "for",
     479              :   "parallel",
     480              :   "sections",
     481              :   "taskgroup",
     482              :   "priority",
     483              :   "grainsize",
     484              :   "num_tasks",
     485              :   "nogroup",
     486              :   "threads",
     487              :   "simd",
     488              :   "hint",
     489              :   "defaultmap",
     490              :   "order",
     491              :   "bind",
     492              :   "filter",
     493              :   "indirect",
     494              :   "partial",
     495              :   "full",
     496              :   "sizes",
     497              :   "_simduid_",
     498              :   "_simt_",
     499              :   "independent",
     500              :   "worker",
     501              :   "vector",
     502              :   "num_gangs",
     503              :   "num_workers",
     504              :   "vector_length",
     505              :   "tile",
     506              :   "if_present",
     507              :   "finalize",
     508              :   "nohost",
     509              :   "novariants",
     510              :   "nocontext",
     511              :   "dyn_groupprivate",
     512              :   "uses_allocators",
     513              :   "message"
     514              : };
     515              : 
     516              : /* Unless specific to OpenACC, we tend to internally maintain OpenMP-centric
     517              :    clause names, but for use in diagnostics etc. would like to use the "user"
     518              :    clause names.  */
     519              : 
     520              : const char *
     521          445 : user_omp_clause_code_name (tree clause, bool oacc)
     522              : {
     523              :   /* For OpenACC, the 'OMP_CLAUSE_MAP_KIND' of an 'OMP_CLAUSE_MAP' is used to
     524              :      distinguish clauses as seen by the user.  See also where front ends do
     525              :      'build_omp_clause' with 'OMP_CLAUSE_MAP'.  */
     526          890 :   if (oacc && OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP)
     527          445 :     switch (OMP_CLAUSE_MAP_KIND (clause))
     528              :       {
     529              :       case GOMP_MAP_FORCE_ALLOC:
     530              :       case GOMP_MAP_ALLOC: return "create";
     531            0 :       case GOMP_MAP_FORCE_TO:
     532            0 :       case GOMP_MAP_TO: return "copyin";
     533            0 :       case GOMP_MAP_FORCE_FROM:
     534            0 :       case GOMP_MAP_FROM: return "copyout";
     535          361 :       case GOMP_MAP_FORCE_TOFROM:
     536          361 :       case GOMP_MAP_TOFROM: return "copy";
     537            0 :       case GOMP_MAP_RELEASE: return "delete";
     538            0 :       case GOMP_MAP_FORCE_PRESENT: return "present";
     539           42 :       case GOMP_MAP_ATTACH: return "attach";
     540           42 :       case GOMP_MAP_FORCE_DETACH:
     541           42 :       case GOMP_MAP_DETACH: return "detach";
     542            0 :       case GOMP_MAP_DEVICE_RESIDENT: return "device_resident";
     543            0 :       case GOMP_MAP_LINK: return "link";
     544            0 :       case GOMP_MAP_FORCE_DEVICEPTR: return "deviceptr";
     545              :       default: break;
     546              :       }
     547              : 
     548            0 :   return omp_clause_code_name[OMP_CLAUSE_CODE (clause)];
     549              : }
     550              : 
     551              : 
     552              : /* Return the tree node structure used by tree code CODE.  */
     553              : 
     554              : static inline enum tree_node_structure_enum
     555  44691197387 : tree_node_structure_for_code (enum tree_code code)
     556              : {
     557  44691197387 :   switch (TREE_CODE_CLASS (code))
     558              :     {
     559  11060219195 :     case tcc_declaration:
     560  11060219195 :       switch (code)
     561              :         {
     562              :         case CONST_DECL:        return TS_CONST_DECL;
     563              :         case DEBUG_EXPR_DECL:   return TS_DECL_WRTL;
     564              :         case FIELD_DECL:        return TS_FIELD_DECL;
     565              :         case FUNCTION_DECL:     return TS_FUNCTION_DECL;
     566              :         case LABEL_DECL:        return TS_LABEL_DECL;
     567              :         case PARM_DECL:         return TS_PARM_DECL;
     568              :         case RESULT_DECL:       return TS_RESULT_DECL;
     569              :         case TRANSLATION_UNIT_DECL: return TS_TRANSLATION_UNIT_DECL;
     570              :         case TYPE_DECL:         return TS_TYPE_DECL;
     571              :         case VAR_DECL:          return TS_VAR_DECL;
     572              :         default:                return TS_DECL_NON_COMMON;
     573              :         }
     574              : 
     575              :     case tcc_type:              return TS_TYPE_NON_COMMON;
     576              : 
     577  11612461000 :     case tcc_binary:
     578  11612461000 :     case tcc_comparison:
     579  11612461000 :     case tcc_expression:
     580  11612461000 :     case tcc_reference:
     581  11612461000 :     case tcc_statement:
     582  11612461000 :     case tcc_unary:
     583  11612461000 :     case tcc_vl_exp:            return TS_EXP;
     584              : 
     585  15957882680 :     default:  /* tcc_constant and tcc_exceptional */
     586  15957882680 :       break;
     587              :     }
     588              : 
     589  15957882680 :   switch (code)
     590              :     {
     591              :       /* tcc_constant cases.  */
     592              :     case COMPLEX_CST:           return TS_COMPLEX;
     593       297180 :     case FIXED_CST:             return TS_FIXED_CST;
     594    780055449 :     case INTEGER_CST:           return TS_INT_CST;
     595       297180 :     case POLY_INT_CST:          return TS_POLY_INT_CST;
     596     49834845 :     case REAL_CST:              return TS_REAL_CST;
     597    260638817 :     case STRING_CST:            return TS_STRING;
     598     14010155 :     case VECTOR_CST:            return TS_VECTOR;
     599      1180705 :     case VOID_CST:              return TS_TYPED;
     600       297437 :     case RAW_DATA_CST:          return TS_RAW_DATA_CST;
     601              : 
     602              :       /* tcc_exceptional cases.  */
     603    738774563 :     case BLOCK:                 return TS_BLOCK;
     604    145998442 :     case CONSTRUCTOR:           return TS_CONSTRUCTOR;
     605              :     case ERROR_MARK:            return TS_COMMON;
     606     10345654 :     case IDENTIFIER_NODE:       return TS_IDENTIFIER;
     607       903842 :     case OMP_CLAUSE:            return TS_OMP_CLAUSE;
     608      2077648 :     case OPTIMIZATION_NODE:     return TS_OPTIMIZATION;
     609              :     case PLACEHOLDER_EXPR:      return TS_COMMON;
     610    353386786 :     case SSA_NAME:              return TS_SSA_NAME;
     611    804974234 :     case STATEMENT_LIST:        return TS_STATEMENT_LIST;
     612      4038811 :     case TARGET_OPTION_NODE:    return TS_TARGET_OPTION;
     613    273963970 :     case TREE_BINFO:            return TS_BINFO;
     614  10302686360 :     case TREE_LIST:             return TS_LIST;
     615   2212130031 :     case TREE_VEC:              return TS_VEC;
     616              : 
     617            0 :     default:
     618            0 :       gcc_unreachable ();
     619              :     }
     620              : }
     621              : 
     622              : 
     623              : /* Initialize tree_contains_struct to describe the hierarchy of tree
     624              :    nodes.  */
     625              : 
     626              : static void
     627       297180 : initialize_tree_contains_struct (void)
     628              : {
     629       297180 :   unsigned i;
     630              : 
     631     73106280 :   for (i = ERROR_MARK; i < LAST_AND_UNUSED_TREE_CODE; i++)
     632              :     {
     633     72809100 :       enum tree_code code;
     634     72809100 :       enum tree_node_structure_enum ts_code;
     635              : 
     636     72809100 :       code = (enum tree_code) i;
     637     72809100 :       ts_code = tree_node_structure_for_code (code);
     638              : 
     639              :       /* Mark the TS structure itself.  */
     640     72809100 :       tree_contains_struct[code][ts_code] = 1;
     641              : 
     642              :       /* Mark all the structures that TS is derived from.  */
     643     72809100 :       switch (ts_code)
     644              :         {
     645      1188720 :         case TS_TYPED:
     646      1188720 :         case TS_BLOCK:
     647      1188720 :         case TS_OPTIMIZATION:
     648      1188720 :         case TS_TARGET_OPTION:
     649      1188720 :           MARK_TS_BASE (code);
     650      1188720 :           break;
     651              : 
     652     60030360 :         case TS_COMMON:
     653     60030360 :         case TS_INT_CST:
     654     60030360 :         case TS_POLY_INT_CST:
     655     60030360 :         case TS_REAL_CST:
     656     60030360 :         case TS_FIXED_CST:
     657     60030360 :         case TS_VECTOR:
     658     60030360 :         case TS_STRING:
     659     60030360 :         case TS_RAW_DATA_CST:
     660     60030360 :         case TS_COMPLEX:
     661     60030360 :         case TS_SSA_NAME:
     662     60030360 :         case TS_CONSTRUCTOR:
     663     60030360 :         case TS_EXP:
     664     60030360 :         case TS_STATEMENT_LIST:
     665     60030360 :           MARK_TS_TYPED (code);
     666     60030360 :           break;
     667              : 
     668      1485900 :         case TS_IDENTIFIER:
     669      1485900 :         case TS_DECL_MINIMAL:
     670      1485900 :         case TS_TYPE_COMMON:
     671      1485900 :         case TS_LIST:
     672      1485900 :         case TS_VEC:
     673      1485900 :         case TS_BINFO:
     674      1485900 :         case TS_OMP_CLAUSE:
     675      1485900 :           MARK_TS_COMMON (code);
     676      1485900 :           break;
     677              : 
     678              :         case TS_TYPE_WITH_LANG_SPECIFIC:
     679              :           MARK_TS_TYPE_COMMON (code);
     680              :           break;
     681              : 
     682      6240780 :         case TS_TYPE_NON_COMMON:
     683      6240780 :           MARK_TS_TYPE_WITH_LANG_SPECIFIC (code);
     684      6240780 :           break;
     685              : 
     686              :         case TS_DECL_COMMON:
     687              :           MARK_TS_DECL_MINIMAL (code);
     688              :           break;
     689              : 
     690       594360 :         case TS_DECL_WRTL:
     691       594360 :         case TS_CONST_DECL:
     692       594360 :           MARK_TS_DECL_COMMON (code);
     693       594360 :           break;
     694              : 
     695       891540 :         case TS_DECL_NON_COMMON:
     696       891540 :           MARK_TS_DECL_WITH_VIS (code);
     697       891540 :           break;
     698              : 
     699       891540 :         case TS_DECL_WITH_VIS:
     700       891540 :         case TS_PARM_DECL:
     701       891540 :         case TS_LABEL_DECL:
     702       891540 :         case TS_RESULT_DECL:
     703       891540 :           MARK_TS_DECL_WRTL (code);
     704       891540 :           break;
     705              : 
     706       297180 :         case TS_FIELD_DECL:
     707       297180 :           MARK_TS_DECL_COMMON (code);
     708       297180 :           break;
     709              : 
     710       297180 :         case TS_VAR_DECL:
     711       297180 :           MARK_TS_DECL_WITH_VIS (code);
     712       297180 :           break;
     713              : 
     714       594360 :         case TS_TYPE_DECL:
     715       594360 :         case TS_FUNCTION_DECL:
     716       594360 :           MARK_TS_DECL_NON_COMMON (code);
     717       594360 :           break;
     718              : 
     719       297180 :         case TS_TRANSLATION_UNIT_DECL:
     720       297180 :           MARK_TS_DECL_COMMON (code);
     721       297180 :           break;
     722              : 
     723              :         default:
     724              :           gcc_unreachable ();
     725              :         }
     726              :     }
     727              : 
     728              :   /* Basic consistency checks for attributes used in fold.  */
     729       297180 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_NON_COMMON]);
     730       297180 :   gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_NON_COMMON]);
     731       297180 :   gcc_assert (tree_contains_struct[CONST_DECL][TS_DECL_COMMON]);
     732       297180 :   gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_COMMON]);
     733       297180 :   gcc_assert (tree_contains_struct[PARM_DECL][TS_DECL_COMMON]);
     734       297180 :   gcc_assert (tree_contains_struct[RESULT_DECL][TS_DECL_COMMON]);
     735       297180 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_COMMON]);
     736       297180 :   gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_COMMON]);
     737       297180 :   gcc_assert (tree_contains_struct[TRANSLATION_UNIT_DECL][TS_DECL_COMMON]);
     738       297180 :   gcc_assert (tree_contains_struct[LABEL_DECL][TS_DECL_COMMON]);
     739       297180 :   gcc_assert (tree_contains_struct[FIELD_DECL][TS_DECL_COMMON]);
     740       297180 :   gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_WRTL]);
     741       297180 :   gcc_assert (tree_contains_struct[PARM_DECL][TS_DECL_WRTL]);
     742       297180 :   gcc_assert (tree_contains_struct[RESULT_DECL][TS_DECL_WRTL]);
     743       297180 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_WRTL]);
     744       297180 :   gcc_assert (tree_contains_struct[LABEL_DECL][TS_DECL_WRTL]);
     745       297180 :   gcc_assert (tree_contains_struct[CONST_DECL][TS_DECL_MINIMAL]);
     746       297180 :   gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_MINIMAL]);
     747       297180 :   gcc_assert (tree_contains_struct[PARM_DECL][TS_DECL_MINIMAL]);
     748       297180 :   gcc_assert (tree_contains_struct[RESULT_DECL][TS_DECL_MINIMAL]);
     749       297180 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_MINIMAL]);
     750       297180 :   gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_MINIMAL]);
     751       297180 :   gcc_assert (tree_contains_struct[TRANSLATION_UNIT_DECL][TS_DECL_MINIMAL]);
     752       297180 :   gcc_assert (tree_contains_struct[LABEL_DECL][TS_DECL_MINIMAL]);
     753       297180 :   gcc_assert (tree_contains_struct[FIELD_DECL][TS_DECL_MINIMAL]);
     754       297180 :   gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_WITH_VIS]);
     755       297180 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_WITH_VIS]);
     756       297180 :   gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_WITH_VIS]);
     757       297180 :   gcc_assert (tree_contains_struct[VAR_DECL][TS_VAR_DECL]);
     758       297180 :   gcc_assert (tree_contains_struct[FIELD_DECL][TS_FIELD_DECL]);
     759       297180 :   gcc_assert (tree_contains_struct[PARM_DECL][TS_PARM_DECL]);
     760       297180 :   gcc_assert (tree_contains_struct[LABEL_DECL][TS_LABEL_DECL]);
     761       297180 :   gcc_assert (tree_contains_struct[RESULT_DECL][TS_RESULT_DECL]);
     762       297180 :   gcc_assert (tree_contains_struct[CONST_DECL][TS_CONST_DECL]);
     763       297180 :   gcc_assert (tree_contains_struct[TYPE_DECL][TS_TYPE_DECL]);
     764       297180 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_FUNCTION_DECL]);
     765       297180 :   gcc_assert (tree_contains_struct[IMPORTED_DECL][TS_DECL_MINIMAL]);
     766       297180 :   gcc_assert (tree_contains_struct[IMPORTED_DECL][TS_DECL_COMMON]);
     767       297180 :   gcc_assert (tree_contains_struct[NAMELIST_DECL][TS_DECL_MINIMAL]);
     768       297180 :   gcc_assert (tree_contains_struct[NAMELIST_DECL][TS_DECL_COMMON]);
     769       297180 : }
     770              : 
     771              : 
     772              : /* Init tree.cc.  */
     773              : 
     774              : void
     775       297180 : init_ttree (void)
     776              : {
     777              :   /* Initialize the hash table of types.  */
     778       297180 :   type_hash_table
     779       297180 :     = hash_table<type_cache_hasher>::create_ggc (TYPE_HASH_INITIAL_SIZE);
     780              : 
     781       297180 :   debug_expr_for_decl
     782       297180 :     = hash_table<tree_decl_map_cache_hasher>::create_ggc (512);
     783              : 
     784       297180 :   value_expr_for_decl
     785       297180 :     = hash_table<tree_decl_map_cache_hasher>::create_ggc (512);
     786              : 
     787       297180 :   int_cst_hash_table = hash_table<int_cst_hasher>::create_ggc (1024);
     788              : 
     789       297180 :   poly_int_cst_hash_table = hash_table<poly_int_cst_hasher>::create_ggc (64);
     790              : 
     791       297180 :   int_cst_node = make_int_cst (1, 1);
     792              : 
     793       297180 :   cl_option_hash_table = hash_table<cl_option_hasher>::create_ggc (64);
     794              : 
     795       297180 :   cl_optimization_node = make_node (OPTIMIZATION_NODE);
     796       297180 :   cl_target_option_node = make_node (TARGET_OPTION_NODE);
     797              : 
     798              :   /* Initialize the tree_contains_struct array.  */
     799       297180 :   initialize_tree_contains_struct ();
     800       297180 :   lang_hooks.init_ts ();
     801       297180 : }
     802              : 
     803              : 
     804              : /* Mapping from prefix to label number.  */
     805              : 
     806              : struct identifier_hash : ggc_ptr_hash <tree_node>
     807              : {
     808        55777 :   static inline hashval_t hash (tree t)
     809              :   {
     810        55777 :     return IDENTIFIER_HASH_VALUE (t);
     811              :   }
     812              : };
     813              : struct identifier_count_traits
     814              :   : simple_hashmap_traits<identifier_hash, long> {};
     815              : typedef hash_map<tree, long, identifier_count_traits> internal_label_map;
     816              : static GTY(()) internal_label_map *internal_label_nums;
     817              : 
     818              : /* Generates an identifier intended to be used internally with the
     819              :    given PREFIX.  This is intended to be used by the frontend so that
     820              :    C++ modules can regenerate appropriate (non-clashing) identifiers on
     821              :    stream-in.  */
     822              : 
     823              : tree
     824        44451 : generate_internal_label (const char *prefix)
     825              : {
     826        44451 :   tree prefix_id = get_identifier (prefix);
     827        44451 :   if (!internal_label_nums)
     828         3102 :     internal_label_nums = internal_label_map::create_ggc();
     829        44451 :   long &num = internal_label_nums->get_or_insert (prefix_id);
     830              : 
     831        44451 :   char tmp[32];
     832        44451 :   ASM_GENERATE_INTERNAL_LABEL (tmp, prefix, num++);
     833              : 
     834        44451 :   tree id = get_identifier (tmp);
     835        44451 :   IDENTIFIER_INTERNAL_P (id) = true;
     836              : 
     837              :   /* Cache the prefix on the identifier so we can retrieve it later.  */
     838        44451 :   TREE_CHAIN (id) = prefix_id;
     839              : 
     840        44451 :   return id;
     841              : }
     842              : 
     843              : /* Get the PREFIX we created the internal identifier LABEL with.  */
     844              : 
     845              : const char *
     846            7 : prefix_for_internal_label (tree label)
     847              : {
     848            7 :   gcc_assert (IDENTIFIER_INTERNAL_P (label)
     849              :               && !IDENTIFIER_TRANSPARENT_ALIAS (label)
     850              :               && TREE_CHAIN (label)
     851              :               && TREE_CODE (TREE_CHAIN (label)) == IDENTIFIER_NODE);
     852            7 :   return IDENTIFIER_POINTER (TREE_CHAIN (label));
     853              : }
     854              : 
     855              : /* The name of the object as the assembler will see it (but before any
     856              :    translations made by ASM_OUTPUT_LABELREF).  Often this is the same
     857              :    as DECL_NAME.  It is an IDENTIFIER_NODE.  */
     858              : tree
     859   1752456971 : decl_assembler_name (tree decl)
     860              : {
     861   1752456971 :   if (!DECL_ASSEMBLER_NAME_SET_P (decl))
     862    171470700 :     lang_hooks.set_decl_assembler_name (decl);
     863   1752456971 :   return DECL_ASSEMBLER_NAME_RAW (decl);
     864              : }
     865              : 
     866              : /* The DECL_ASSEMBLER_NAME_RAW of DECL is being explicitly set to NAME
     867              :    (either of which may be NULL).  Inform the FE, if this changes the
     868              :    name.  */
     869              : 
     870              : void
     871    923633464 : overwrite_decl_assembler_name (tree decl, tree name)
     872              : {
     873    923633464 :   if (DECL_ASSEMBLER_NAME_RAW (decl) != name)
     874    459251858 :     lang_hooks.overwrite_decl_assembler_name (decl, name);
     875    923633464 : }
     876              : 
     877              : /* Return true if DECL may need an assembler name to be set.  */
     878              : 
     879              : static inline bool
     880      5182477 : need_assembler_name_p (tree decl)
     881              : {
     882              :   /* We use DECL_ASSEMBLER_NAME to hold mangled type names for One Definition
     883              :      Rule merging.  This makes type_odr_p to return true on those types during
     884              :      LTO and by comparing the mangled name, we can say what types are intended
     885              :      to be equivalent across compilation unit.
     886              : 
     887              :      We do not store names of type_in_anonymous_namespace_p.
     888              : 
     889              :      Record, union and enumeration type have linkage that allows use
     890              :      to check type_in_anonymous_namespace_p. We do not mangle compound types
     891              :      that always can be compared structurally.
     892              : 
     893              :      Similarly for builtin types, we compare properties of their main variant.
     894              :      A special case are integer types where mangling do make differences
     895              :      between char/signed char/unsigned char etc.  Storing name for these makes
     896              :      e.g.  -fno-signed-char/-fsigned-char mismatches to be handled well.
     897              :      See cp/mangle.cc:write_builtin_type for details.  */
     898              : 
     899      5182477 :   if (TREE_CODE (decl) == TYPE_DECL)
     900              :     {
     901       160806 :       if (DECL_NAME (decl)
     902       131311 :           && decl == TYPE_NAME (TREE_TYPE (decl))
     903       131152 :           && TYPE_MAIN_VARIANT (TREE_TYPE (decl)) == TREE_TYPE (decl)
     904       111182 :           && !TYPE_ARTIFICIAL (TREE_TYPE (decl))
     905       108162 :           && ((TREE_CODE (TREE_TYPE (decl)) != RECORD_TYPE
     906        90123 :                && TREE_CODE (TREE_TYPE (decl)) != UNION_TYPE)
     907        18297 :               || TYPE_CXX_ODR_P (TREE_TYPE (decl)))
     908       106761 :           && (type_with_linkage_p (TREE_TYPE (decl))
     909        91742 :               || TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE)
     910       231789 :           && !variably_modified_type_p (TREE_TYPE (decl), NULL_TREE))
     911        70983 :         return !DECL_ASSEMBLER_NAME_SET_P (decl);
     912              :       return false;
     913              :     }
     914              :   /* Only FUNCTION_DECLs and VAR_DECLs are considered.  */
     915      5021671 :   if (!VAR_OR_FUNCTION_DECL_P (decl))
     916              :     return false;
     917              : 
     918              :   /* If DECL already has its assembler name set, it does not need a
     919              :      new one.  */
     920      4318906 :   if (!HAS_DECL_ASSEMBLER_NAME_P (decl)
     921      4318906 :       || DECL_ASSEMBLER_NAME_SET_P (decl))
     922              :     return false;
     923              : 
     924              :   /* Abstract decls do not need an assembler name, except they
     925              :      can be looked up by autofdo.  */
     926      1731501 :   if (DECL_ABSTRACT_P (decl) && !flag_auto_profile)
     927              :     return false;
     928              : 
     929              :   /* For VAR_DECLs, only static, public and external symbols need an
     930              :      assembler name.  */
     931      1730121 :   if (VAR_P (decl)
     932       550806 :       && !TREE_STATIC (decl)
     933       550481 :       && !TREE_PUBLIC (decl)
     934      2280602 :       && !DECL_EXTERNAL (decl))
     935              :     return false;
     936              : 
     937      1179640 :   if (TREE_CODE (decl) == FUNCTION_DECL)
     938              :     {
     939              :       /* Do not set assembler name on builtins.  Allow RTL expansion to
     940              :          decide whether to expand inline or via a regular call.  */
     941      1179315 :       if (fndecl_built_in_p (decl)
     942      1179315 :           && DECL_BUILT_IN_CLASS (decl) != BUILT_IN_FRONTEND)
     943              :         return false;
     944              : 
     945              :       /* Functions represented in the callgraph need an assembler name.  */
     946      1174600 :       if (cgraph_node::get (decl) != NULL)
     947              :         return true;
     948              : 
     949              :       /* Unused and not public functions don't need an assembler name.  */
     950         3390 :       if (!TREE_USED (decl) && !TREE_PUBLIC (decl))
     951            3 :         return false;
     952              :     }
     953              : 
     954              :   return true;
     955              : }
     956              : 
     957              : /* If T needs an assembler name, have one created for it.  */
     958              : 
     959              : void
     960      5182477 : assign_assembler_name_if_needed (tree t)
     961              : {
     962      5182477 :   if (need_assembler_name_p (t))
     963              :     {
     964              :       /* When setting DECL_ASSEMBLER_NAME, the C++ mangler may emit
     965              :          diagnostics that use input_location to show locus
     966              :          information.  The problem here is that, at this point,
     967              :          input_location is generally anchored to the end of the file
     968              :          (since the parser is long gone), so we don't have a good
     969              :          position to pin it to.
     970              : 
     971              :          To alleviate this problem, this uses the location of T's
     972              :          declaration.  Examples of this are
     973              :          testsuite/g++.dg/template/cond2.C and
     974              :          testsuite/g++.dg/template/pr35240.C.  */
     975      1245882 :       location_t saved_location = input_location;
     976      1245882 :       input_location = DECL_SOURCE_LOCATION (t);
     977              : 
     978      1245882 :       decl_assembler_name (t);
     979              : 
     980      1245882 :       input_location = saved_location;
     981              :     }
     982      5182477 : }
     983              : 
     984              : /* When the target supports COMDAT groups, this indicates which group the
     985              :    DECL is associated with.  This can be either an IDENTIFIER_NODE or a
     986              :    decl, in which case its DECL_ASSEMBLER_NAME identifies the group.  */
     987              : tree
     988    403941805 : decl_comdat_group (const_tree node)
     989              : {
     990    403941805 :   struct symtab_node *snode = symtab_node::get (node);
     991    403941805 :   if (!snode)
     992              :     return NULL;
     993    386571490 :   return snode->get_comdat_group ();
     994              : }
     995              : 
     996              : /* Likewise, but make sure it's been reduced to an IDENTIFIER_NODE.  */
     997              : tree
     998        12107 : decl_comdat_group_id (const_tree node)
     999              : {
    1000        12107 :   struct symtab_node *snode = symtab_node::get (node);
    1001        12107 :   if (!snode)
    1002              :     return NULL;
    1003        12107 :   return snode->get_comdat_group_id ();
    1004              : }
    1005              : 
    1006              : /* When the target supports named section, return its name as IDENTIFIER_NODE
    1007              :    or NULL if it is in no section.  */
    1008              : const char *
    1009    762299314 : decl_section_name (const_tree node)
    1010              : {
    1011    762299314 :   struct symtab_node *snode = symtab_node::get (node);
    1012    762299314 :   if (!snode)
    1013              :     return NULL;
    1014    576266049 :   return snode->get_section ();
    1015              : }
    1016              : 
    1017              : /* Set section name of NODE to VALUE (that is expected to be
    1018              :    identifier node) */
    1019              : void
    1020      1823994 : set_decl_section_name (tree node, const char *value)
    1021              : {
    1022      1823994 :   struct symtab_node *snode;
    1023              : 
    1024      1823994 :   if (value == NULL)
    1025              :     {
    1026          237 :       snode = symtab_node::get (node);
    1027          237 :       if (!snode)
    1028              :         return;
    1029              :     }
    1030              :   else
    1031      1823757 :     snode = symtab_node::get_create (node);
    1032      1823994 :   snode->set_section (value);
    1033              : }
    1034              : 
    1035              : /* Set section name of NODE to match the section name of OTHER.
    1036              : 
    1037              :    set_decl_section_name (decl, other) is equivalent to
    1038              :    set_decl_section_name (decl, DECL_SECTION_NAME (other)), but possibly more
    1039              :    efficient.  */
    1040              : void
    1041     16541243 : set_decl_section_name (tree decl, const_tree other)
    1042              : {
    1043     16541243 :   struct symtab_node *other_node = symtab_node::get (other);
    1044     16541243 :   if (other_node)
    1045              :     {
    1046     16539802 :       struct symtab_node *decl_node = symtab_node::get_create (decl);
    1047     16539802 :       decl_node->set_section (*other_node);
    1048              :     }
    1049              :   else
    1050              :     {
    1051         1441 :       struct symtab_node *decl_node = symtab_node::get (decl);
    1052         1441 :       if (!decl_node)
    1053              :     return;
    1054            0 :       decl_node->set_section (NULL);
    1055              :     }
    1056              : }
    1057              : 
    1058              : /* Return TLS model of a variable NODE.  */
    1059              : enum tls_model
    1060    283408257 : decl_tls_model (const_tree node)
    1061              : {
    1062    283408257 :   struct varpool_node *snode = varpool_node::get (node);
    1063    283408257 :   if (!snode)
    1064              :     return TLS_MODEL_NONE;
    1065    234354554 :   return snode->tls_model;
    1066              : }
    1067              : 
    1068              : /* Set TLS model of variable NODE to MODEL.  */
    1069              : void
    1070        57730 : set_decl_tls_model (tree node, enum tls_model model)
    1071              : {
    1072        57730 :   struct varpool_node *vnode;
    1073              : 
    1074        57730 :   if (model == TLS_MODEL_NONE)
    1075              :     {
    1076         6124 :       vnode = varpool_node::get (node);
    1077         6124 :       if (!vnode)
    1078              :         return;
    1079              :     }
    1080              :   else
    1081        51606 :     vnode = varpool_node::get_create (node);
    1082        51606 :   vnode->tls_model = model;
    1083              : }
    1084              : 
    1085              : /* Compute the number of bytes occupied by a tree with code CODE.
    1086              :    This function cannot be used for nodes that have variable sizes,
    1087              :    including TREE_VEC, INTEGER_CST, STRING_CST, and CALL_EXPR.  */
    1088              : size_t
    1089  19262072834 : tree_code_size (enum tree_code code)
    1090              : {
    1091  19262072834 :   switch (TREE_CODE_CLASS (code))
    1092              :     {
    1093   4636193010 :     case tcc_declaration:  /* A decl node */
    1094   4636193010 :       switch (code)
    1095              :         {
    1096              :         case FIELD_DECL:        return sizeof (tree_field_decl);
    1097              :         case PARM_DECL:         return sizeof (tree_parm_decl);
    1098    283292783 :         case VAR_DECL:          return sizeof (tree_var_decl);
    1099              :         case LABEL_DECL:        return sizeof (tree_label_decl);
    1100              :         case RESULT_DECL:       return sizeof (tree_result_decl);
    1101     31300321 :         case CONST_DECL:        return sizeof (tree_const_decl);
    1102              :         case TYPE_DECL:         return sizeof (tree_type_decl);
    1103   1505186501 :         case FUNCTION_DECL:     return sizeof (tree_function_decl);
    1104              :         case DEBUG_EXPR_DECL:   return sizeof (tree_decl_with_rtl);
    1105              :         case TRANSLATION_UNIT_DECL: return sizeof (tree_translation_unit_decl);
    1106              :         case NAMESPACE_DECL:
    1107              :         case IMPORTED_DECL:
    1108              :         case NAMELIST_DECL:     return sizeof (tree_decl_non_common);
    1109    298699906 :         default:
    1110    298699906 :           gcc_checking_assert (code >= NUM_TREE_CODES);
    1111    298699906 :           return lang_hooks.tree_size (code);
    1112              :         }
    1113              : 
    1114   3201235419 :     case tcc_type:  /* a type node */
    1115   3201235419 :       switch (code)
    1116              :         {
    1117              :         case OFFSET_TYPE:
    1118              :         case ENUMERAL_TYPE:
    1119              :         case BOOLEAN_TYPE:
    1120              :         case INTEGER_TYPE:
    1121              :         case REAL_TYPE:
    1122              :         case OPAQUE_TYPE:
    1123              :         case POINTER_TYPE:
    1124              :         case REFERENCE_TYPE:
    1125              :         case NULLPTR_TYPE:
    1126              :         case FIXED_POINT_TYPE:
    1127              :         case COMPLEX_TYPE:
    1128              :         case VECTOR_TYPE:
    1129              :         case ARRAY_TYPE:
    1130              :         case RECORD_TYPE:
    1131              :         case UNION_TYPE:
    1132              :         case QUAL_UNION_TYPE:
    1133              :         case VOID_TYPE:
    1134              :         case FUNCTION_TYPE:
    1135              :         case METHOD_TYPE:
    1136              :         case BITINT_TYPE:
    1137              :         case LANG_TYPE:         return sizeof (tree_type_non_common);
    1138    762580640 :         default:
    1139    762580640 :           gcc_checking_assert (code >= NUM_TREE_CODES);
    1140    762580640 :           return lang_hooks.tree_size (code);
    1141              :         }
    1142              : 
    1143   5275040397 :     case tcc_reference:   /* a reference */
    1144   5275040397 :     case tcc_expression:  /* an expression */
    1145   5275040397 :     case tcc_statement:   /* an expression with side effects */
    1146   5275040397 :     case tcc_comparison:  /* a comparison expression */
    1147   5275040397 :     case tcc_unary:       /* a unary arithmetic expression */
    1148   5275040397 :     case tcc_binary:      /* a binary arithmetic expression */
    1149   5275040397 :       return (sizeof (struct tree_exp)
    1150   5275040397 :               + (TREE_CODE_LENGTH (code) - 1) * sizeof (tree));
    1151              : 
    1152     44385109 :     case tcc_constant:  /* a constant */
    1153     44385109 :       switch (code)
    1154              :         {
    1155              :         case VOID_CST:          return sizeof (tree_typed);
    1156            0 :         case INTEGER_CST:       gcc_unreachable ();
    1157              :         case POLY_INT_CST:      return sizeof (tree_poly_int_cst);
    1158     43529441 :         case REAL_CST:          return sizeof (tree_real_cst);
    1159              :         case FIXED_CST:         return sizeof (tree_fixed_cst);
    1160              :         case COMPLEX_CST:       return sizeof (tree_complex);
    1161              :         case RAW_DATA_CST:      return sizeof (tree_raw_data);
    1162            0 :         case VECTOR_CST:        gcc_unreachable ();
    1163            0 :         case STRING_CST:        gcc_unreachable ();
    1164        64360 :         default:
    1165        64360 :           gcc_checking_assert (code >= NUM_TREE_CODES);
    1166        64360 :           return lang_hooks.tree_size (code);
    1167              :         }
    1168              : 
    1169   6105218899 :     case tcc_exceptional:  /* something random, like an identifier.  */
    1170   6105218899 :       switch (code)
    1171              :         {
    1172   1792261342 :         case IDENTIFIER_NODE:   return lang_hooks.identifier_size;
    1173              :         case TREE_LIST:         return sizeof (tree_list);
    1174              : 
    1175              :         case ERROR_MARK:
    1176              :         case PLACEHOLDER_EXPR:  return sizeof (tree_common);
    1177              : 
    1178            0 :         case TREE_VEC:          gcc_unreachable ();
    1179            0 :         case OMP_CLAUSE:        gcc_unreachable ();
    1180              : 
    1181              :         case SSA_NAME:          return sizeof (tree_ssa_name);
    1182              : 
    1183              :         case STATEMENT_LIST:    return sizeof (tree_statement_list);
    1184    317320810 :         case BLOCK:             return sizeof (struct tree_block);
    1185              :         case CONSTRUCTOR:       return sizeof (tree_constructor);
    1186              :         case OPTIMIZATION_NODE: return sizeof (tree_optimization_option);
    1187              :         case TARGET_OPTION_NODE: return sizeof (tree_target_option);
    1188              : 
    1189   1674206308 :         default:
    1190   1674206308 :           gcc_checking_assert (code >= NUM_TREE_CODES);
    1191   1674206308 :           return lang_hooks.tree_size (code);
    1192              :         }
    1193              : 
    1194            0 :     default:
    1195            0 :       gcc_unreachable ();
    1196              :     }
    1197              : }
    1198              : 
    1199              : /* Compute the number of bytes occupied by NODE.  This routine only
    1200              :    looks at TREE_CODE, except for those nodes that have variable sizes.  */
    1201              : size_t
    1202   4646891443 : tree_size (const_tree node)
    1203              : {
    1204   4646891443 :   const enum tree_code code = TREE_CODE (node);
    1205   4646891443 :   switch (code)
    1206              :     {
    1207       540702 :     case INTEGER_CST:
    1208       540702 :       return (sizeof (struct tree_int_cst)
    1209       540702 :               + (TREE_INT_CST_EXT_NUNITS (node) - 1) * sizeof (HOST_WIDE_INT));
    1210              : 
    1211            0 :     case TREE_BINFO:
    1212            0 :       return (offsetof (struct tree_binfo, base_binfos)
    1213              :               + vec<tree, va_gc>
    1214            0 :                   ::embedded_size (BINFO_N_BASE_BINFOS (node)));
    1215              : 
    1216    425469281 :     case TREE_VEC:
    1217    425469281 :       return (sizeof (struct tree_vec)
    1218    425469281 :               + (TREE_VEC_LENGTH (node) - 1) * sizeof (tree));
    1219              : 
    1220            0 :     case VECTOR_CST:
    1221            0 :       return (sizeof (struct tree_vector)
    1222            0 :               + (vector_cst_encoded_nelts (node) - 1) * sizeof (tree));
    1223              : 
    1224        23692 :     case STRING_CST:
    1225        23692 :       return TREE_STRING_LENGTH (node) + offsetof (struct tree_string, str) + 1;
    1226              : 
    1227        34355 :     case OMP_CLAUSE:
    1228        34355 :       return (sizeof (struct tree_omp_clause)
    1229        34355 :               + (omp_clause_num_ops[OMP_CLAUSE_CODE (node)] - 1)
    1230        34355 :                 * sizeof (tree));
    1231              : 
    1232   4220823413 :     default:
    1233   4220823413 :       if (TREE_CODE_CLASS (code) == tcc_vl_exp)
    1234    196038163 :         return (sizeof (struct tree_exp)
    1235    196038163 :                 + (VL_EXP_OPERAND_LENGTH (node) - 1) * sizeof (tree));
    1236              :       else
    1237   4024785250 :         return tree_code_size (code);
    1238              :     }
    1239              : }
    1240              : 
    1241              : /* Return tree node kind based on tree CODE.  */
    1242              : 
    1243              : static tree_node_kind
    1244            0 : get_stats_node_kind (enum tree_code code)
    1245              : {
    1246            0 :   enum tree_code_class type = TREE_CODE_CLASS (code);
    1247              : 
    1248            0 :   switch (type)
    1249              :     {
    1250              :     case tcc_declaration:  /* A decl node */
    1251              :       return d_kind;
    1252            0 :     case tcc_type:  /* a type node */
    1253            0 :       return t_kind;
    1254            0 :     case tcc_statement:  /* an expression with side effects */
    1255            0 :       return s_kind;
    1256            0 :     case tcc_reference:  /* a reference */
    1257            0 :       return r_kind;
    1258              :     case tcc_expression:  /* an expression */
    1259              :     case tcc_comparison:  /* a comparison expression */
    1260              :     case tcc_unary:  /* a unary arithmetic expression */
    1261              :     case tcc_binary:  /* a binary arithmetic expression */
    1262              :       return e_kind;
    1263            0 :     case tcc_constant:  /* a constant */
    1264            0 :       return c_kind;
    1265            0 :     case tcc_exceptional:  /* something random, like an identifier.  */
    1266            0 :       switch (code)
    1267              :         {
    1268              :         case IDENTIFIER_NODE:
    1269              :           return id_kind;
    1270            0 :         case TREE_VEC:
    1271            0 :           return vec_kind;
    1272            0 :         case TREE_BINFO:
    1273            0 :           return binfo_kind;
    1274            0 :         case SSA_NAME:
    1275            0 :           return ssa_name_kind;
    1276            0 :         case BLOCK:
    1277            0 :           return b_kind;
    1278            0 :         case CONSTRUCTOR:
    1279            0 :           return constr_kind;
    1280            0 :         case OMP_CLAUSE:
    1281            0 :           return omp_clause_kind;
    1282            0 :         default:
    1283            0 :           return x_kind;
    1284              :         }
    1285              :       break;
    1286              :     case tcc_vl_exp:
    1287              :       return e_kind;
    1288            0 :     default:
    1289            0 :       gcc_unreachable ();
    1290              :     }
    1291              : }
    1292              : 
    1293              : /* Record interesting allocation statistics for a tree node with CODE
    1294              :    and LENGTH.  */
    1295              : 
    1296              : static void
    1297            0 : record_node_allocation_statistics (enum tree_code code, size_t length)
    1298              : {
    1299            0 :   if (!GATHER_STATISTICS)
    1300            0 :     return;
    1301              : 
    1302              :   tree_node_kind kind = get_stats_node_kind (code);
    1303              : 
    1304              :   tree_code_counts[(int) code]++;
    1305              :   tree_node_counts[(int) kind]++;
    1306              :   tree_node_sizes[(int) kind] += length;
    1307              : }
    1308              : 
    1309              : /* Allocate and return a new UID from the DECL_UID namespace.  */
    1310              : 
    1311              : int
    1312   4629444659 : allocate_decl_uid (void)
    1313              : {
    1314   4629444659 :   return next_decl_uid++;
    1315              : }
    1316              : 
    1317              : /* Return a newly allocated node of code CODE.  For decl and type
    1318              :    nodes, some other fields are initialized.  The rest of the node is
    1319              :    initialized to zero.  This function cannot be used for TREE_VEC,
    1320              :    INTEGER_CST or OMP_CLAUSE nodes, which is enforced by asserts in
    1321              :    tree_code_size.
    1322              : 
    1323              :    Achoo!  I got a code in the node.  */
    1324              : 
    1325              : tree
    1326  15231475026 : make_node (enum tree_code code MEM_STAT_DECL)
    1327              : {
    1328  15231475026 :   tree t;
    1329  15231475026 :   enum tree_code_class type = TREE_CODE_CLASS (code);
    1330  15231475026 :   size_t length = tree_code_size (code);
    1331              : 
    1332  15231475026 :   record_node_allocation_statistics (code, length);
    1333              : 
    1334  15231475026 :   t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
    1335  15231475026 :   TREE_SET_CODE (t, code);
    1336              : 
    1337  15231475026 :   switch (type)
    1338              :     {
    1339    788303149 :     case tcc_statement:
    1340    788303149 :       if (code != DEBUG_BEGIN_STMT)
    1341    415024256 :         TREE_SIDE_EFFECTS (t) = 1;
    1342              :       break;
    1343              : 
    1344   3312535600 :     case tcc_declaration:
    1345   3312535600 :       if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
    1346              :         {
    1347   3312535600 :           if (code == FUNCTION_DECL)
    1348              :             {
    1349   1181383845 :               SET_DECL_ALIGN (t, FUNCTION_ALIGNMENT (FUNCTION_BOUNDARY));
    1350   1181383845 :               SET_DECL_MODE (t, FUNCTION_MODE);
    1351              :             }
    1352              :           else
    1353   2131151755 :             SET_DECL_ALIGN (t, 1);
    1354              :         }
    1355   3312535600 :       DECL_SOURCE_LOCATION (t) = input_location;
    1356   3312535600 :       if (TREE_CODE (t) == DEBUG_EXPR_DECL)
    1357      2035076 :         DECL_UID (t) = --next_debug_decl_uid;
    1358              :       else
    1359              :         {
    1360   3310500524 :           DECL_UID (t) = allocate_decl_uid ();
    1361   3310500524 :           SET_DECL_PT_UID (t, -1);
    1362              :         }
    1363   3312535600 :       if (TREE_CODE (t) == LABEL_DECL)
    1364     38156408 :         LABEL_DECL_UID (t) = -1;
    1365              : 
    1366              :       break;
    1367              : 
    1368   2373172037 :     case tcc_type:
    1369   2373172037 :       TYPE_UID (t) = next_type_uid++;
    1370   2373172037 :       SET_TYPE_ALIGN (t, BITS_PER_UNIT);
    1371   2373172037 :       TYPE_USER_ALIGN (t) = 0;
    1372   2373172037 :       TYPE_MAIN_VARIANT (t) = t;
    1373   2373172037 :       TYPE_CANONICAL (t) = t;
    1374              : 
    1375              :       /* Default to no attributes for type, but let target change that.  */
    1376   2373172037 :       TYPE_ATTRIBUTES (t) = NULL_TREE;
    1377   2373172037 :       targetm.set_default_type_attributes (t);
    1378              : 
    1379              :       /* We have not yet computed the alias set for this type.  */
    1380   2373172037 :       TYPE_ALIAS_SET (t) = -1;
    1381   2373172037 :       break;
    1382              : 
    1383     44383244 :     case tcc_constant:
    1384     44383244 :       TREE_CONSTANT (t) = 1;
    1385     44383244 :       break;
    1386              : 
    1387   1373522368 :     case tcc_expression:
    1388   1373522368 :       switch (code)
    1389              :         {
    1390    296580952 :         case INIT_EXPR:
    1391    296580952 :         case MODIFY_EXPR:
    1392    296580952 :         case VA_ARG_EXPR:
    1393    296580952 :         case PREDECREMENT_EXPR:
    1394    296580952 :         case PREINCREMENT_EXPR:
    1395    296580952 :         case POSTDECREMENT_EXPR:
    1396    296580952 :         case POSTINCREMENT_EXPR:
    1397              :           /* All of these have side-effects, no matter what their
    1398              :              operands are.  */
    1399    296580952 :           TREE_SIDE_EFFECTS (t) = 1;
    1400    296580952 :           break;
    1401              : 
    1402              :         default:
    1403              :           break;
    1404              :         }
    1405              :       break;
    1406              : 
    1407   5878179188 :     case tcc_exceptional:
    1408   5878179188 :       switch (code)
    1409              :         {
    1410      1117826 :         case TARGET_OPTION_NODE:
    1411      2235652 :           TREE_TARGET_OPTION(t)
    1412      1117826 :                             = ggc_cleared_alloc<struct cl_target_option> ();
    1413      1117826 :           break;
    1414              : 
    1415       619361 :         case OPTIMIZATION_NODE:
    1416      1238722 :           TREE_OPTIMIZATION (t)
    1417       619361 :                             = ggc_cleared_alloc<struct cl_optimization> ();
    1418       619361 :           break;
    1419              : 
    1420              :         default:
    1421              :           break;
    1422              :         }
    1423              :       break;
    1424              : 
    1425              :     default:
    1426              :       /* Other classes need no special treatment.  */
    1427              :       break;
    1428              :     }
    1429              : 
    1430  15231475026 :   return t;
    1431              : }
    1432              : 
    1433              : /* Free tree node.  */
    1434              : 
    1435              : void
    1436    684363791 : free_node (tree node)
    1437              : {
    1438    684363791 :   enum tree_code code = TREE_CODE (node);
    1439    684363791 :   if (GATHER_STATISTICS)
    1440              :     {
    1441              :       enum tree_node_kind kind = get_stats_node_kind (code);
    1442              : 
    1443              :       gcc_checking_assert (tree_code_counts[(int) TREE_CODE (node)] != 0);
    1444              :       gcc_checking_assert (tree_node_counts[(int) kind] != 0);
    1445              :       gcc_checking_assert (tree_node_sizes[(int) kind] >= tree_size (node));
    1446              : 
    1447              :       tree_code_counts[(int) TREE_CODE (node)]--;
    1448              :       tree_node_counts[(int) kind]--;
    1449              :       tree_node_sizes[(int) kind] -= tree_size (node);
    1450              :     }
    1451    684363791 :   if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
    1452          349 :     vec_free (CONSTRUCTOR_ELTS (node));
    1453    684363598 :   else if (code == BLOCK)
    1454            0 :     vec_free (BLOCK_NONLOCALIZED_VARS (node));
    1455    684363598 :   else if (code == TREE_BINFO)
    1456          369 :     vec_free (BINFO_BASE_ACCESSES (node));
    1457    684363229 :   else if (code == OPTIMIZATION_NODE)
    1458          888 :     cl_optimization_option_free (TREE_OPTIMIZATION (node));
    1459    684362341 :   else if (code == TARGET_OPTION_NODE)
    1460          954 :     cl_target_option_free (TREE_TARGET_OPTION (node));
    1461    684363791 :   ggc_free (node);
    1462    684363791 : }
    1463              : 
    1464              : /* Return a new node with the same contents as NODE except that its
    1465              :    TREE_CHAIN, if it has one, is zero and it has a fresh uid.  */
    1466              : 
    1467              : tree
    1468   4560540198 : copy_node (tree node MEM_STAT_DECL)
    1469              : {
    1470   4560540198 :   tree t;
    1471   4560540198 :   enum tree_code code = TREE_CODE (node);
    1472   4560540198 :   size_t length;
    1473              : 
    1474   4560540198 :   gcc_assert (code != STATEMENT_LIST);
    1475              : 
    1476   4560540198 :   length = tree_size (node);
    1477   4560540198 :   record_node_allocation_statistics (code, length);
    1478   4560540198 :   t = ggc_alloc_tree_node_stat (length PASS_MEM_STAT);
    1479   4560540198 :   memcpy (t, node, length);
    1480              : 
    1481   4560540198 :   if (CODE_CONTAINS_STRUCT (code, TS_COMMON))
    1482   2622224151 :     TREE_CHAIN (t) = 0;
    1483   4560540198 :   TREE_ASM_WRITTEN (t) = 0;
    1484   4560540198 :   TREE_VISITED (t) = 0;
    1485              : 
    1486   4560540198 :   if (TREE_CODE_CLASS (code) == tcc_declaration)
    1487              :     {
    1488   1317844852 :       if (code == DEBUG_EXPR_DECL)
    1489            0 :         DECL_UID (t) = --next_debug_decl_uid;
    1490              :       else
    1491              :         {
    1492   1317844852 :           DECL_UID (t) = allocate_decl_uid ();
    1493   1317844852 :           if (DECL_PT_UID_SET_P (node))
    1494         3534 :             SET_DECL_PT_UID (t, DECL_PT_UID (node));
    1495              :         }
    1496    656931796 :       if ((TREE_CODE (node) == PARM_DECL || VAR_P (node))
    1497   1406041148 :           && DECL_HAS_VALUE_EXPR_P (node))
    1498              :         {
    1499      1279623 :           SET_DECL_VALUE_EXPR (t, DECL_VALUE_EXPR (node));
    1500      1279623 :           DECL_HAS_VALUE_EXPR_P (t) = 1;
    1501              :         }
    1502              :       /* DECL_DEBUG_EXPR is copied explicitly by callers.  */
    1503   1317844852 :       if (VAR_P (node))
    1504              :         {
    1505     88196296 :           DECL_HAS_DEBUG_EXPR_P (t) = 0;
    1506     88196296 :           t->decl_with_vis.symtab_node = NULL;
    1507              :         }
    1508   1317844852 :       if (VAR_P (node) && DECL_HAS_INIT_PRIORITY_P (node))
    1509              :         {
    1510            0 :           SET_DECL_INIT_PRIORITY (t, DECL_INIT_PRIORITY (node));
    1511            0 :           DECL_HAS_INIT_PRIORITY_P (t) = 1;
    1512              :         }
    1513   1317844852 :       if (TREE_CODE (node) == FUNCTION_DECL)
    1514              :         {
    1515    318617538 :           DECL_STRUCT_FUNCTION (t) = NULL;
    1516    318617538 :           t->decl_with_vis.symtab_node = NULL;
    1517              :         }
    1518              :     }
    1519   3242695346 :   else if (TREE_CODE_CLASS (code) == tcc_type)
    1520              :     {
    1521    828063382 :       TYPE_UID (t) = next_type_uid++;
    1522              :       /* The following is so that the debug code for
    1523              :          the copy is different from the original type.
    1524              :          The two statements usually duplicate each other
    1525              :          (because they clear fields of the same union),
    1526              :          but the optimizer should catch that.  */
    1527    828063382 :       TYPE_SYMTAB_ADDRESS (t) = 0;
    1528    828063382 :       TYPE_SYMTAB_DIE (t) = 0;
    1529              : 
    1530              :       /* Do not copy the values cache.  */
    1531    828063382 :       if (TYPE_CACHED_VALUES_P (t))
    1532              :         {
    1533     19947103 :           TYPE_CACHED_VALUES_P (t) = 0;
    1534     19947103 :           TYPE_CACHED_VALUES (t) = NULL_TREE;
    1535              :         }
    1536              :     }
    1537   2414631964 :     else if (code == TARGET_OPTION_NODE)
    1538              :       {
    1539            0 :         TREE_TARGET_OPTION (t) = ggc_alloc<struct cl_target_option>();
    1540            0 :         memcpy (TREE_TARGET_OPTION (t), TREE_TARGET_OPTION (node),
    1541              :                 sizeof (struct cl_target_option));
    1542              :       }
    1543   2414631964 :     else if (code == OPTIMIZATION_NODE)
    1544              :       {
    1545            0 :         TREE_OPTIMIZATION (t) = ggc_alloc<struct cl_optimization>();
    1546            0 :         memcpy (TREE_OPTIMIZATION (t), TREE_OPTIMIZATION (node),
    1547              :                 sizeof (struct cl_optimization));
    1548              :       }
    1549              : 
    1550   4560540198 :   return t;
    1551              : }
    1552              : 
    1553              : /* Return a copy of a chain of nodes, chained through the TREE_CHAIN field.
    1554              :    For example, this can copy a list made of TREE_LIST nodes.  */
    1555              : 
    1556              : tree
    1557    168615668 : copy_list (tree list)
    1558              : {
    1559    168615668 :   tree head;
    1560    168615668 :   tree prev, next;
    1561              : 
    1562    168615668 :   if (list == 0)
    1563              :     return 0;
    1564              : 
    1565    163298979 :   head = prev = copy_node (list);
    1566    163298979 :   next = TREE_CHAIN (list);
    1567    320526325 :   while (next)
    1568              :     {
    1569    157227346 :       TREE_CHAIN (prev) = copy_node (next);
    1570    157227346 :       prev = TREE_CHAIN (prev);
    1571    157227346 :       next = TREE_CHAIN (next);
    1572              :     }
    1573              :   return head;
    1574              : }
    1575              : 
    1576              : 
    1577              : /* Return the value that TREE_INT_CST_EXT_NUNITS should have for an
    1578              :    INTEGER_CST with value CST and type TYPE.   */
    1579              : 
    1580              : static unsigned int
    1581  11176417398 : get_int_cst_ext_nunits (tree type, const wide_int &cst)
    1582              : {
    1583  11176417398 :   gcc_checking_assert (cst.get_precision () == TYPE_PRECISION (type));
    1584              :   /* We need extra HWIs if CST is an unsigned integer with its
    1585              :      upper bit set.  */
    1586  11176417398 :   if (TYPE_UNSIGNED (type) && wi::neg_p (cst))
    1587    190334580 :     return cst.get_precision () / HOST_BITS_PER_WIDE_INT + 1;
    1588  10986082818 :   return cst.get_len ();
    1589              : }
    1590              : 
    1591              : /* Return a new INTEGER_CST with value CST and type TYPE.  */
    1592              : 
    1593              : static tree
    1594    137423782 : build_new_int_cst (tree type, const wide_int &cst)
    1595              : {
    1596    137423782 :   unsigned int len = cst.get_len ();
    1597    137423782 :   unsigned int ext_len = get_int_cst_ext_nunits (type, cst);
    1598    137423782 :   tree nt = make_int_cst (len, ext_len);
    1599              : 
    1600    137423782 :   if (len < ext_len)
    1601              :     {
    1602     70147361 :       --ext_len;
    1603    140294722 :       TREE_INT_CST_ELT (nt, ext_len)
    1604     70147361 :         = zext_hwi (-1, cst.get_precision () % HOST_BITS_PER_WIDE_INT);
    1605     93189959 :       for (unsigned int i = len; i < ext_len; ++i)
    1606     23042598 :         TREE_INT_CST_ELT (nt, i) = -1;
    1607              :     }
    1608     67276421 :   else if (TYPE_UNSIGNED (type)
    1609     67276421 :            && cst.get_precision () < len * HOST_BITS_PER_WIDE_INT)
    1610              :     {
    1611     15180654 :       len--;
    1612     30361308 :       TREE_INT_CST_ELT (nt, len)
    1613     15180654 :         = zext_hwi (cst.elt (len),
    1614     15180654 :                     cst.get_precision () % HOST_BITS_PER_WIDE_INT);
    1615              :     }
    1616              : 
    1617    263239357 :   for (unsigned int i = 0; i < len; i++)
    1618    125815575 :     TREE_INT_CST_ELT (nt, i) = cst.elt (i);
    1619    137423782 :   TREE_TYPE (nt) = type;
    1620    137423782 :   return nt;
    1621              : }
    1622              : 
    1623              : /* Return a new POLY_INT_CST with coefficients COEFFS and type TYPE.  */
    1624              : 
    1625              : static tree
    1626            0 : build_new_poly_int_cst (tree type, tree (&coeffs)[NUM_POLY_INT_COEFFS]
    1627              :                         CXX_MEM_STAT_INFO)
    1628              : {
    1629            0 :   size_t length = sizeof (struct tree_poly_int_cst);
    1630            0 :   record_node_allocation_statistics (POLY_INT_CST, length);
    1631              : 
    1632            0 :   tree t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
    1633              : 
    1634            0 :   TREE_SET_CODE (t, POLY_INT_CST);
    1635            0 :   TREE_CONSTANT (t) = 1;
    1636            0 :   TREE_TYPE (t) = type;
    1637            0 :   for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    1638            0 :     POLY_INT_CST_COEFF (t, i) = coeffs[i];
    1639            0 :   return t;
    1640              : }
    1641              : 
    1642              : /* Create a constant tree that contains CST sign-extended to TYPE.  */
    1643              : 
    1644              : tree
    1645   7363888100 : build_int_cst (tree type, poly_int64 cst)
    1646              : {
    1647              :   /* Support legacy code.  */
    1648   7363888100 :   if (!type)
    1649           48 :     type = integer_type_node;
    1650              : 
    1651   7363888100 :   return wide_int_to_tree (type, wi::shwi (cst, TYPE_PRECISION (type)));
    1652              : }
    1653              : 
    1654              : /* Create a constant tree that contains CST zero-extended to TYPE.  */
    1655              : 
    1656              : tree
    1657      9975827 : build_int_cstu (tree type, poly_uint64 cst)
    1658              : {
    1659      9975827 :   return wide_int_to_tree (type, wi::uhwi (cst, TYPE_PRECISION (type)));
    1660              : }
    1661              : 
    1662              : /* Create a constant tree that contains CST sign-extended to TYPE.  */
    1663              : 
    1664              : tree
    1665     28125671 : build_int_cst_type (tree type, poly_int64 cst)
    1666              : {
    1667     28125671 :   gcc_assert (type);
    1668     28125671 :   return wide_int_to_tree (type, wi::shwi (cst, TYPE_PRECISION (type)));
    1669              : }
    1670              : 
    1671              : /* Constructs tree in type TYPE from with value given by CST.  Signedness
    1672              :    of CST is assumed to be the same as the signedness of TYPE.  */
    1673              : 
    1674              : tree
    1675      7298166 : double_int_to_tree (tree type, double_int cst)
    1676              : {
    1677      7298166 :   return wide_int_to_tree (type, widest_int::from (cst, TYPE_SIGN (type)));
    1678              : }
    1679              : 
    1680              : /* We force the wide_int CST to the range of the type TYPE by sign or
    1681              :    zero extending it.  OVERFLOWABLE indicates if we are interested in
    1682              :    overflow of the value, when >0 we are only interested in signed
    1683              :    overflow, for <0 we are interested in any overflow.  OVERFLOWED
    1684              :    indicates whether overflow has already occurred.  CONST_OVERFLOWED
    1685              :    indicates whether constant overflow has already occurred.  We force
    1686              :    T's value to be within range of T's type (by setting to 0 or 1 all
    1687              :    the bits outside the type's range).  We set TREE_OVERFLOWED if,
    1688              :         OVERFLOWED is nonzero,
    1689              :         or OVERFLOWABLE is >0 and signed overflow occurs
    1690              :         or OVERFLOWABLE is <0 and any overflow occurs
    1691              :    We return a new tree node for the extended wide_int.  The node
    1692              :    is shared if no overflow flags are set.  */
    1693              : 
    1694              : 
    1695              : tree
    1696   3035852812 : force_fit_type (tree type, const poly_wide_int_ref &cst,
    1697              :                 int overflowable, bool overflowed)
    1698              : {
    1699   3035852812 :   signop sign = TYPE_SIGN (type);
    1700              : 
    1701              :   /* If we need to set overflow flags, return a new unshared node.  */
    1702   3035852812 :   if (overflowed || !wi::fits_to_tree_p (cst, type))
    1703              :     {
    1704      7215187 :       if (overflowed
    1705      7215187 :           || overflowable < 0
    1706      5966549 :           || (overflowable > 0 && sign == SIGNED))
    1707              :         {
    1708      1330973 :           poly_wide_int tmp = poly_wide_int::from (cst, TYPE_PRECISION (type),
    1709      1330973 :                                                    sign);
    1710      1330973 :           tree t;
    1711      1330973 :           if (tmp.is_constant ())
    1712      1330973 :             t = build_new_int_cst (type, tmp.coeffs[0]);
    1713              :           else
    1714              :             {
    1715              :               tree coeffs[NUM_POLY_INT_COEFFS];
    1716              :               for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    1717              :                 {
    1718              :                   coeffs[i] = build_new_int_cst (type, tmp.coeffs[i]);
    1719              :                   TREE_OVERFLOW (coeffs[i]) = 1;
    1720              :                 }
    1721              :               t = build_new_poly_int_cst (type, coeffs);
    1722              :             }
    1723      1330973 :           TREE_OVERFLOW (t) = 1;
    1724      1330973 :           return t;
    1725      1330973 :         }
    1726              :     }
    1727              : 
    1728              :   /* Else build a shared node.  */
    1729   3034521839 :   return wide_int_to_tree (type, cst);
    1730              : }
    1731              : 
    1732              : /* These are the hash table functions for the hash table of INTEGER_CST
    1733              :    nodes of a sizetype.  */
    1734              : 
    1735              : /* Return the hash code X, an INTEGER_CST.  */
    1736              : 
    1737              : hashval_t
    1738   2968756845 : int_cst_hasher::hash (tree x)
    1739              : {
    1740   2968756845 :   const_tree const t = x;
    1741   2968756845 :   hashval_t code = TYPE_UID (TREE_TYPE (t));
    1742   2968756845 :   int i;
    1743              : 
    1744   5946084958 :   for (i = 0; i < TREE_INT_CST_NUNITS (t); i++)
    1745   2977328113 :     code = iterative_hash_host_wide_int (TREE_INT_CST_ELT(t, i), code);
    1746              : 
    1747   2968756845 :   return code;
    1748              : }
    1749              : 
    1750              : /* Return nonzero if the value represented by *X (an INTEGER_CST tree node)
    1751              :    is the same as that given by *Y, which is the same.  */
    1752              : 
    1753              : bool
    1754   2913095650 : int_cst_hasher::equal (tree x, tree y)
    1755              : {
    1756   2913095650 :   const_tree const xt = x;
    1757   2913095650 :   const_tree const yt = y;
    1758              : 
    1759   2913095650 :   if (TREE_TYPE (xt) != TREE_TYPE (yt)
    1760    949284586 :       || TREE_INT_CST_NUNITS (xt) != TREE_INT_CST_NUNITS (yt)
    1761   3862322319 :       || TREE_INT_CST_EXT_NUNITS (xt) != TREE_INT_CST_EXT_NUNITS (yt))
    1762              :     return false;
    1763              : 
    1764   1306813687 :   for (int i = 0; i < TREE_INT_CST_NUNITS (xt); i++)
    1765    913543518 :     if (TREE_INT_CST_ELT (xt, i) != TREE_INT_CST_ELT (yt, i))
    1766              :       return false;
    1767              : 
    1768              :   return true;
    1769              : }
    1770              : 
    1771              : /* Cache wide_int CST into the TYPE_CACHED_VALUES cache for TYPE.
    1772              :    SLOT is the slot entry to store it in, and MAX_SLOTS is the maximum
    1773              :    number of slots that can be cached for the type.  */
    1774              : 
    1775              : static inline tree
    1776  10477647011 : cache_wide_int_in_type_cache (tree type, const wide_int &cst,
    1777              :                               int slot, int max_slots)
    1778              : {
    1779  10477647011 :   gcc_checking_assert (slot >= 0);
    1780              :   /* Initialize cache.  */
    1781  10477647011 :   if (!TYPE_CACHED_VALUES_P (type))
    1782              :     {
    1783     20594023 :       TYPE_CACHED_VALUES_P (type) = 1;
    1784     20594023 :       TYPE_CACHED_VALUES (type) = make_tree_vec (max_slots);
    1785              :     }
    1786  10477647011 :   tree t = TREE_VEC_ELT (TYPE_CACHED_VALUES (type), slot);
    1787  10477647011 :   if (!t)
    1788              :     {
    1789              :       /* Create a new shared int.  */
    1790     63601911 :       t = build_new_int_cst (type, cst);
    1791     63601911 :       TREE_VEC_ELT (TYPE_CACHED_VALUES (type), slot) = t;
    1792              :     }
    1793  10477647011 :   return t;
    1794              : }
    1795              : 
    1796              : /* Create an INT_CST node of TYPE and value CST.
    1797              :    The returned node is always shared.  For small integers we use a
    1798              :    per-type vector cache, for larger ones we use a single hash table.
    1799              :    The value is extended from its precision according to the sign of
    1800              :    the type to be a multiple of HOST_BITS_PER_WIDE_INT.  This defines
    1801              :    the upper bits and ensures that hashing and value equality based
    1802              :    upon the underlying HOST_WIDE_INTs works without masking.  */
    1803              : 
    1804              : static tree
    1805  11038993616 : wide_int_to_tree_1 (tree type, const wide_int_ref &pcst)
    1806              : {
    1807  11038993616 :   tree t;
    1808  11038993616 :   int ix = -1;
    1809  11038993616 :   int limit = 0;
    1810              : 
    1811  11038993616 :   gcc_assert (type);
    1812  11038993616 :   unsigned int prec = TYPE_PRECISION (type);
    1813  11038993616 :   signop sgn = TYPE_SIGN (type);
    1814              : 
    1815              :   /* Verify that everything is canonical.  */
    1816  11038993616 :   int l = pcst.get_len ();
    1817  11038993616 :   if (l > 1)
    1818              :     {
    1819      4039154 :       if (pcst.elt (l - 1) == 0)
    1820      1128409 :         gcc_checking_assert (pcst.elt (l - 2) < 0);
    1821      4039154 :       if (pcst.elt (l - 1) == HOST_WIDE_INT_M1)
    1822        11966 :         gcc_checking_assert (pcst.elt (l - 2) >= 0);
    1823              :     }
    1824              : 
    1825  11038993616 :   wide_int cst = wide_int::from (pcst, prec, sgn);
    1826  11038993616 :   unsigned int ext_len = get_int_cst_ext_nunits (type, cst);
    1827              : 
    1828  11038993616 :   enum tree_code code = TREE_CODE (type);
    1829  11038993616 :   if (code == POINTER_TYPE || code == REFERENCE_TYPE)
    1830              :     {
    1831              :       /* Cache NULL pointer and zero bounds.  */
    1832    194405038 :       if (cst == 0)
    1833              :         ix = 0;
    1834              :       /* Cache upper bounds of pointers.  */
    1835     51581001 :       else if (cst == wi::max_value (prec, sgn))
    1836              :         ix = 1;
    1837              :       /* Cache 1 which is used for a non-zero range.  */
    1838     49439841 :       else if (cst == 1)
    1839              :         ix = 2;
    1840              : 
    1841              :       if (ix >= 0)
    1842              :         {
    1843    150820034 :           t = cache_wide_int_in_type_cache (type, cst, ix, 3);
    1844              :           /* Make sure no one is clobbering the shared constant.  */
    1845    150820034 :           gcc_checking_assert (TREE_TYPE (t) == type
    1846              :                                && cst == wi::to_wide (t));
    1847    150820034 :           return t;
    1848              :         }
    1849              :     }
    1850  10888173582 :   if (ext_len == 1)
    1851              :     {
    1852              :       /* We just need to store a single HOST_WIDE_INT.  */
    1853  10815682684 :       HOST_WIDE_INT hwi;
    1854  10815682684 :       if (TYPE_UNSIGNED (type))
    1855   7282139292 :         hwi = cst.to_uhwi ();
    1856              :       else
    1857   3533609671 :         hwi = cst.to_shwi ();
    1858              : 
    1859  10815682684 :       switch (code)
    1860              :         {
    1861              :         /* This could represent the C++ std::meta::info type.  */
    1862          883 :         case OPAQUE_TYPE:
    1863          883 :           gcc_assert (SCALAR_INT_MODE_P (TYPE_MODE (type)));
    1864              :           /* Fallthru.  */
    1865       229677 :         case NULLPTR_TYPE:
    1866       229677 :           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    135440620 :         case BOOLEAN_TYPE:
    1875              :           /* Cache false or true.  */
    1876    135440620 :           limit = 2;
    1877    135440620 :           if (IN_RANGE (hwi, 0, 1))
    1878    135233486 :             ix = hwi;
    1879              :           break;
    1880              : 
    1881  10621474248 :         case INTEGER_TYPE:
    1882  10621474248 :         case OFFSET_TYPE:
    1883  10621474248 :         case BITINT_TYPE:
    1884  10621474248 :           if (TYPE_SIGN (type) == UNSIGNED)
    1885              :             {
    1886              :               /* Cache [0, N).  */
    1887   7094152702 :               limit = param_integer_share_limit;
    1888   7094152702 :               if (IN_RANGE (hwi, 0, param_integer_share_limit - 1))
    1889   6814342832 :                 ix = hwi;
    1890              :             }
    1891              :           else
    1892              :             {
    1893              :               /* Cache [-1, N).  */
    1894   3527321546 :               limit = param_integer_share_limit + 1;
    1895   3527321546 :               if (IN_RANGE (hwi, -1, param_integer_share_limit - 1))
    1896   3377250659 :                 ix = hwi + 1;
    1897              :             }
    1898              :           break;
    1899              : 
    1900              :         case ENUMERAL_TYPE:
    1901              :           break;
    1902              : 
    1903            0 :         default:
    1904            0 :           gcc_unreachable ();
    1905              :         }
    1906              : 
    1907  10815682684 :       if (ix >= 0)
    1908              :         {
    1909  10326826977 :           t = cache_wide_int_in_type_cache (type, cst, ix, limit);
    1910              :           /* Make sure no one is clobbering the shared constant.  */
    1911  20653653954 :           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    488855707 :           TREE_INT_CST_ELT (int_cst_node, 0) = hwi;
    1923    488855707 :           TREE_TYPE (int_cst_node) = type;
    1924              : 
    1925    488855707 :           tree *slot = int_cst_hash_table->find_slot (int_cst_node, INSERT);
    1926    488855707 :           t = *slot;
    1927    488855707 :           if (!t)
    1928              :             {
    1929              :               /* Insert this one into the hash table.  */
    1930    155975387 :               t = int_cst_node;
    1931    155975387 :               *slot = t;
    1932              :               /* Make a new node for next time round.  */
    1933    155975387 :               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     72490898 :       tree nt = build_new_int_cst (type, cst);
    1944     72490898 :       tree *slot = int_cst_hash_table->find_slot (nt, INSERT);
    1945     72490898 :       t = *slot;
    1946     72490898 :       if (!t)
    1947              :         {
    1948              :           /* Insert this one into the hash table.  */
    1949     12870565 :           t = nt;
    1950     12870565 :           *slot = t;
    1951              :         }
    1952              :       else
    1953     59620333 :         ggc_free (nt);
    1954              :     }
    1955              : 
    1956              :   return t;
    1957  11038993616 : }
    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  11038993616 : wide_int_to_tree (tree type, const poly_wide_int_ref &value)
    2013              : {
    2014  11038993616 :   if (value.is_constant ())
    2015  11038993616 :     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       642202 : cache_integer_cst (tree t, bool might_duplicate ATTRIBUTE_UNUSED)
    2028              : {
    2029       642202 :   tree type = TREE_TYPE (t);
    2030       642202 :   int ix = -1;
    2031       642202 :   int limit = 0;
    2032       642202 :   int prec = TYPE_PRECISION (type);
    2033              : 
    2034       642202 :   gcc_assert (!TREE_OVERFLOW (t));
    2035              : 
    2036              :   /* The caching indices here must match those in
    2037              :      wide_int_to_type_1.  */
    2038       642202 :   switch (TREE_CODE (type))
    2039              :     {
    2040              :     /* This could represent the C++ std::meta::info type.  */
    2041            2 :     case OPAQUE_TYPE:
    2042            2 :       gcc_assert (SCALAR_INT_MODE_P (TYPE_MODE (type)));
    2043              :       /* Fallthru.  */
    2044            2 :     case NULLPTR_TYPE:
    2045            2 :       gcc_checking_assert (integer_zerop (t));
    2046              :       /* Fallthru.  */
    2047              : 
    2048         4997 :     case POINTER_TYPE:
    2049         4997 :     case REFERENCE_TYPE:
    2050         4997 :       {
    2051         4997 :         if (integer_zerop (t))
    2052              :           ix = 0;
    2053         1981 :         else if (integer_onep (t))
    2054              :           ix = 2;
    2055              : 
    2056              :         if (ix >= 0)
    2057              :           limit = 3;
    2058              :       }
    2059              :       break;
    2060              : 
    2061        11163 :     case BOOLEAN_TYPE:
    2062              :       /* Cache false or true.  */
    2063        11163 :       limit = 2;
    2064        11163 :       if (wi::ltu_p (wi::to_wide (t), 2))
    2065            0 :         ix = TREE_INT_CST_ELT (t, 0);
    2066              :       break;
    2067              : 
    2068       610944 :     case INTEGER_TYPE:
    2069       610944 :     case OFFSET_TYPE:
    2070       610944 :     case BITINT_TYPE:
    2071       610944 :       if (TYPE_UNSIGNED (type))
    2072              :         {
    2073              :           /* Cache 0..N */
    2074       453706 :           limit = param_integer_share_limit;
    2075              : 
    2076              :           /* This is a little hokie, but if the prec is smaller than
    2077              :              what is necessary to hold param_integer_share_limit, then the
    2078              :              obvious test will not get the correct answer.  */
    2079       453706 :           if (prec < HOST_BITS_PER_WIDE_INT)
    2080              :             {
    2081        96462 :               if (tree_to_uhwi (t)
    2082        96462 :                   < (unsigned HOST_WIDE_INT) param_integer_share_limit)
    2083        16759 :                 ix = tree_to_uhwi (t);
    2084              :             }
    2085       357244 :           else if (wi::ltu_p (wi::to_wide (t), param_integer_share_limit))
    2086       278447 :             ix = tree_to_uhwi (t);
    2087              :         }
    2088              :       else
    2089              :         {
    2090              :           /* Cache -1..N */
    2091       157238 :           limit = param_integer_share_limit + 1;
    2092              : 
    2093       157238 :           if (integer_minus_onep (t))
    2094              :             ix = 0;
    2095       156772 :           else if (!wi::neg_p (wi::to_wide (t)))
    2096              :             {
    2097       138909 :               if (prec < HOST_BITS_PER_WIDE_INT)
    2098              :                 {
    2099       132200 :                   if (tree_to_shwi (t) < param_integer_share_limit)
    2100       123101 :                     ix = tree_to_shwi (t) + 1;
    2101              :                 }
    2102         6709 :               else if (wi::ltu_p (wi::to_wide (t), param_integer_share_limit))
    2103         5450 :                 ix = tree_to_shwi (t) + 1;
    2104              :             }
    2105              :         }
    2106              :       break;
    2107              : 
    2108              :     case ENUMERAL_TYPE:
    2109              :       /* The slot used by TYPE_CACHED_VALUES is used for the enum
    2110              :          members.  */
    2111              :       break;
    2112              : 
    2113            0 :     default:
    2114            0 :       gcc_unreachable ();
    2115              :     }
    2116              : 
    2117       426773 :   if (ix >= 0)
    2118              :     {
    2119              :       /* Look for it in the type's vector of small shared ints.  */
    2120       427764 :       if (!TYPE_CACHED_VALUES_P (type))
    2121              :         {
    2122        14760 :           TYPE_CACHED_VALUES_P (type) = 1;
    2123        14760 :           TYPE_CACHED_VALUES (type) = make_tree_vec (limit);
    2124              :         }
    2125              : 
    2126       427764 :       if (tree r = TREE_VEC_ELT (TYPE_CACHED_VALUES (type), ix))
    2127              :         {
    2128       401656 :           gcc_checking_assert (might_duplicate);
    2129       401656 :           t = r;
    2130              :         }
    2131              :       else
    2132        26108 :         TREE_VEC_ELT (TYPE_CACHED_VALUES (type), ix) = t;
    2133              :     }
    2134              :   else
    2135              :     {
    2136              :       /* Use the cache of larger shared ints.  */
    2137       214438 :       tree *slot = int_cst_hash_table->find_slot (t, INSERT);
    2138       214438 :       if (tree r = *slot)
    2139              :         {
    2140              :           /* If there is already an entry for the number verify it's the
    2141              :              same value.  */
    2142       126114 :           gcc_checking_assert (wi::to_wide (tree (r)) == wi::to_wide (t));
    2143              :           /* And return the cached value.  */
    2144       126114 :           t = r;
    2145              :         }
    2146              :       else
    2147              :         /* Otherwise insert this one into the hash table.  */
    2148        88324 :         *slot = t;
    2149              :     }
    2150              : 
    2151       642202 :   return t;
    2152              : }
    2153              : 
    2154              : 
    2155              : /* Builds an integer constant in TYPE such that lowest BITS bits are ones
    2156              :    and the rest are zeros.  */
    2157              : 
    2158              : tree
    2159     10220416 : build_low_bits_mask (tree type, unsigned bits)
    2160              : {
    2161     10220416 :   gcc_assert (bits <= TYPE_PRECISION (type));
    2162              : 
    2163     10220416 :   return wide_int_to_tree (type, wi::mask (bits, false,
    2164     10220416 :                                            TYPE_PRECISION (type)));
    2165              : }
    2166              : 
    2167              : /* Checks that X is integer constant that can be expressed in (unsigned)
    2168              :    HOST_WIDE_INT without loss of precision.  */
    2169              : 
    2170              : bool
    2171    789603734 : cst_and_fits_in_hwi (const_tree x)
    2172              : {
    2173    789603734 :   return (TREE_CODE (x) == INTEGER_CST
    2174    789603734 :           && (tree_fits_shwi_p (x) || tree_fits_uhwi_p (x)));
    2175              : }
    2176              : 
    2177              : /* Build a newly constructed VECTOR_CST with the given values of
    2178              :    (VECTOR_CST_)LOG2_NPATTERNS and (VECTOR_CST_)NELTS_PER_PATTERN.  */
    2179              : 
    2180              : tree
    2181      3497527 : make_vector (unsigned log2_npatterns,
    2182              :              unsigned int nelts_per_pattern MEM_STAT_DECL)
    2183              : {
    2184      3497527 :   gcc_assert (IN_RANGE (nelts_per_pattern, 1, 3));
    2185      3497527 :   tree t;
    2186      3497527 :   unsigned npatterns = 1 << log2_npatterns;
    2187      3497527 :   unsigned encoded_nelts = npatterns * nelts_per_pattern;
    2188      3497527 :   unsigned length = (sizeof (struct tree_vector)
    2189              :                      + (encoded_nelts - 1) * sizeof (tree));
    2190              : 
    2191      3497527 :   record_node_allocation_statistics (VECTOR_CST, length);
    2192              : 
    2193      3497527 :   t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
    2194              : 
    2195      3497527 :   TREE_SET_CODE (t, VECTOR_CST);
    2196      3497527 :   TREE_CONSTANT (t) = 1;
    2197      3497527 :   VECTOR_CST_LOG2_NPATTERNS (t) = log2_npatterns;
    2198      3497527 :   VECTOR_CST_NELTS_PER_PATTERN (t) = nelts_per_pattern;
    2199              : 
    2200      3497527 :   return t;
    2201              : }
    2202              : 
    2203              : /* Return a new VECTOR_CST node whose type is TYPE and whose values
    2204              :    are extracted from V, a vector of CONSTRUCTOR_ELT.  */
    2205              : 
    2206              : tree
    2207       693762 : build_vector_from_ctor (tree type, const vec<constructor_elt, va_gc> *v)
    2208              : {
    2209       693762 :   if (vec_safe_length (v) == 0)
    2210         2051 :     return build_zero_cst (type);
    2211              : 
    2212       691711 :   unsigned HOST_WIDE_INT idx, npatterns, nelts_per_pattern;
    2213       691711 :   tree value;
    2214              : 
    2215              :   /* If the vector is a VLA, build a VLA constant vector.  */
    2216       691711 :   npatterns = constant_lower_bound (TYPE_VECTOR_SUBPARTS (type));
    2217       691711 :   nelts_per_pattern = TYPE_VECTOR_SUBPARTS (type).is_constant () ? 1 : 2;
    2218       691711 :   gcc_assert (vec_safe_length (v) <= npatterns);
    2219              : 
    2220       691711 :   tree_vector_builder vec (type, npatterns, nelts_per_pattern);
    2221      5275274 :   FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value)
    2222              :     {
    2223      3891852 :       if (TREE_CODE (value) == VECTOR_CST)
    2224              :         {
    2225              :           /* If NPATTERNS is constant then this must be too.  */
    2226         4912 :           unsigned int sub_nelts = VECTOR_CST_NELTS (value).to_constant ();
    2227        19984 :           for (unsigned i = 0; i < sub_nelts; ++i)
    2228        15072 :             vec.quick_push (VECTOR_CST_ELT (value, i));
    2229              :         }
    2230              :       else
    2231      3886940 :         vec.quick_push (value);
    2232              :     }
    2233      1968020 :   while (vec.length () < npatterns * nelts_per_pattern)
    2234       292299 :     vec.quick_push (build_zero_cst (TREE_TYPE (type)));
    2235              : 
    2236       691711 :   return vec.build ();
    2237       691711 : }
    2238              : 
    2239              : /* Build a vector of type VECTYPE where all the elements are SCs.  */
    2240              : tree
    2241       665841 : build_vector_from_val (tree vectype, tree sc)
    2242              : {
    2243       665841 :   unsigned HOST_WIDE_INT i, nunits;
    2244              : 
    2245       665841 :   if (sc == error_mark_node)
    2246              :     return sc;
    2247              : 
    2248              :   /* Verify that the vector type is suitable for SC.  Note that there
    2249              :      is some inconsistency in the type-system with respect to restrict
    2250              :      qualifications of pointers.  Vector types always have a main-variant
    2251              :      element type and the qualification is applied to the vector-type.
    2252              :      So TREE_TYPE (vector-type) does not return a properly qualified
    2253              :      vector element-type.  */
    2254       665841 :   gcc_checking_assert (types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (sc)),
    2255              :                                            TREE_TYPE (vectype)));
    2256              : 
    2257       665841 :   if (CONSTANT_CLASS_P (sc))
    2258              :     {
    2259       634472 :       tree_vector_builder v (vectype, 1, 1);
    2260       634472 :       v.quick_push (sc);
    2261       634472 :       return v.build ();
    2262       634472 :     }
    2263        31369 :   else if (!TYPE_VECTOR_SUBPARTS (vectype).is_constant (&nunits))
    2264              :     return fold_build1 (VEC_DUPLICATE_EXPR, vectype, sc);
    2265              :   else
    2266              :     {
    2267        31369 :       vec<constructor_elt, va_gc> *v;
    2268        31369 :       vec_alloc (v, nunits);
    2269       182048 :       for (i = 0; i < nunits; ++i)
    2270       119310 :         CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, sc);
    2271        31369 :       return build_constructor (vectype, v);
    2272              :     }
    2273              : }
    2274              : 
    2275              : /* If TYPE is not a vector type, just return SC, otherwise return
    2276              :    build_vector_from_val (TYPE, SC).  */
    2277              : 
    2278              : tree
    2279      5603677 : build_uniform_cst (tree type, tree sc)
    2280              : {
    2281      5603677 :   if (!VECTOR_TYPE_P (type))
    2282              :     return sc;
    2283              : 
    2284          372 :   return build_vector_from_val (type, sc);
    2285              : }
    2286              : 
    2287              : /* Build a vector series of type TYPE in which element I has the value
    2288              :    BASE + I * STEP.  The result is a constant if BASE and STEP are constant
    2289              :    and a VEC_SERIES_EXPR otherwise.  */
    2290              : 
    2291              : tree
    2292           21 : build_vec_series (tree type, tree base, tree step)
    2293              : {
    2294           21 :   if (integer_zerop (step))
    2295            0 :     return build_vector_from_val (type, base);
    2296           21 :   if (TREE_CODE (base) == INTEGER_CST && TREE_CODE (step) == INTEGER_CST)
    2297              :     {
    2298           21 :       tree_vector_builder builder (type, 1, 3);
    2299           21 :       tree elt1 = wide_int_to_tree (TREE_TYPE (base),
    2300           42 :                                     wi::to_wide (base) + wi::to_wide (step));
    2301           21 :       tree elt2 = wide_int_to_tree (TREE_TYPE (base),
    2302           42 :                                     wi::to_wide (elt1) + wi::to_wide (step));
    2303           21 :       builder.quick_push (base);
    2304           21 :       builder.quick_push (elt1);
    2305           21 :       builder.quick_push (elt2);
    2306           21 :       return builder.build ();
    2307           21 :     }
    2308            0 :   return build2 (VEC_SERIES_EXPR, type, base, step);
    2309              : }
    2310              : 
    2311              : /* Return a vector with the same number of units and number of bits
    2312              :    as VEC_TYPE, but in which the elements are a linear series of unsigned
    2313              :    integers { BASE, BASE + STEP, BASE + STEP * 2, ... }.  */
    2314              : 
    2315              : tree
    2316         1810 : build_index_vector (tree vec_type, poly_uint64 base, poly_uint64 step)
    2317              : {
    2318         1810 :   tree index_vec_type = vec_type;
    2319         1810 :   tree index_elt_type = TREE_TYPE (vec_type);
    2320         1810 :   poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (vec_type);
    2321         1810 :   if (!INTEGRAL_TYPE_P (index_elt_type) || !TYPE_UNSIGNED (index_elt_type))
    2322              :     {
    2323            4 :       index_elt_type = build_nonstandard_integer_type
    2324            8 :         (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (index_elt_type)), true);
    2325            4 :       index_vec_type = build_vector_type (index_elt_type, nunits);
    2326              :     }
    2327              : 
    2328         1810 :   tree_vector_builder v (index_vec_type, 1, 3);
    2329         9050 :   for (unsigned int i = 0; i < 3; ++i)
    2330         5430 :     v.quick_push (build_int_cstu (index_elt_type, base + i * step));
    2331         1810 :   return v.build ();
    2332         1810 : }
    2333              : 
    2334              : /* Return a VECTOR_CST of type VEC_TYPE in which the first NUM_A
    2335              :    elements are A and the rest are B.  */
    2336              : 
    2337              : tree
    2338            0 : build_vector_a_then_b (tree vec_type, unsigned int num_a, tree a, tree b)
    2339              : {
    2340            0 :   gcc_assert (known_le (num_a, TYPE_VECTOR_SUBPARTS (vec_type)));
    2341            0 :   unsigned int count = constant_lower_bound (TYPE_VECTOR_SUBPARTS (vec_type));
    2342              :   /* Optimize the constant case.  */
    2343            0 :   if ((count & 1) == 0 && TYPE_VECTOR_SUBPARTS (vec_type).is_constant ())
    2344            0 :     count /= 2;
    2345            0 :   tree_vector_builder builder (vec_type, count, 2);
    2346            0 :   for (unsigned int i = 0; i < count * 2; ++i)
    2347            0 :     builder.quick_push (i < num_a ? a : b);
    2348            0 :   return builder.build ();
    2349            0 : }
    2350              : 
    2351              : /* Something has messed with the elements of CONSTRUCTOR C after it was built;
    2352              :    calculate TREE_CONSTANT and TREE_SIDE_EFFECTS.  */
    2353              : 
    2354              : void
    2355    167576847 : recompute_constructor_flags (tree c)
    2356              : {
    2357    167576847 :   unsigned int i;
    2358    167576847 :   tree val;
    2359    167576847 :   bool constant_p = true;
    2360    167576847 :   bool side_effects_p = false;
    2361    167576847 :   vec<constructor_elt, va_gc> *vals = CONSTRUCTOR_ELTS (c);
    2362              : 
    2363    348851915 :   FOR_EACH_CONSTRUCTOR_VALUE (vals, i, val)
    2364              :     {
    2365              :       /* Mostly ctors will have elts that don't have side-effects, so
    2366              :          the usual case is to scan all the elements.  Hence a single
    2367              :          loop for both const and side effects, rather than one loop
    2368              :          each (with early outs).  */
    2369    181275068 :       if (!TREE_CONSTANT (val))
    2370     22556135 :         constant_p = false;
    2371    181275068 :       if (TREE_SIDE_EFFECTS (val))
    2372      4660653 :         side_effects_p = true;
    2373              :     }
    2374              : 
    2375    167576847 :   TREE_SIDE_EFFECTS (c) = side_effects_p;
    2376    167576847 :   TREE_CONSTANT (c) = constant_p;
    2377    167576847 : }
    2378              : 
    2379              : /* Make sure that TREE_CONSTANT and TREE_SIDE_EFFECTS are correct for
    2380              :    CONSTRUCTOR C.  */
    2381              : 
    2382              : void
    2383     20035255 : verify_constructor_flags (tree c)
    2384              : {
    2385     20035255 :   unsigned int i;
    2386     20035255 :   tree val;
    2387     20035255 :   bool constant_p = TREE_CONSTANT (c);
    2388     20035255 :   bool side_effects_p = TREE_SIDE_EFFECTS (c);
    2389     20035255 :   vec<constructor_elt, va_gc> *vals = CONSTRUCTOR_ELTS (c);
    2390              : 
    2391    175148902 :   FOR_EACH_CONSTRUCTOR_VALUE (vals, i, val)
    2392              :     {
    2393    155113647 :       if (constant_p && !TREE_CONSTANT (val))
    2394            0 :         internal_error ("non-constant element in constant CONSTRUCTOR");
    2395    155113647 :       if (!side_effects_p && TREE_SIDE_EFFECTS (val))
    2396            0 :         internal_error ("side-effects element in no-side-effects CONSTRUCTOR");
    2397              :     }
    2398     20035255 : }
    2399              : 
    2400              : /* Return a new CONSTRUCTOR node whose type is TYPE and whose values
    2401              :    are in the vec pointed to by VALS.  */
    2402              : tree
    2403    142981400 : build_constructor (tree type, vec<constructor_elt, va_gc> *vals MEM_STAT_DECL)
    2404              : {
    2405    142981400 :   tree c = make_node (CONSTRUCTOR PASS_MEM_STAT);
    2406              : 
    2407    142981400 :   TREE_TYPE (c) = type;
    2408    142981400 :   CONSTRUCTOR_ELTS (c) = vals;
    2409              : 
    2410    142981400 :   recompute_constructor_flags (c);
    2411              : 
    2412    142981400 :   return c;
    2413              : }
    2414              : 
    2415              : /* Build a CONSTRUCTOR node made of a single initializer, with the specified
    2416              :    INDEX and VALUE.  */
    2417              : tree
    2418         7073 : build_constructor_single (tree type, tree index, tree value)
    2419              : {
    2420         7073 :   vec<constructor_elt, va_gc> *v;
    2421         7073 :   constructor_elt elt = {index, value};
    2422              : 
    2423         7073 :   vec_alloc (v, 1);
    2424         7073 :   v->quick_push (elt);
    2425              : 
    2426         7073 :   return build_constructor (type, v);
    2427              : }
    2428              : 
    2429              : 
    2430              : /* Return a new CONSTRUCTOR node whose type is TYPE and whose values
    2431              :    are in a list pointed to by VALS.  */
    2432              : tree
    2433         1013 : build_constructor_from_list (tree type, tree vals)
    2434              : {
    2435         1013 :   tree t;
    2436         1013 :   vec<constructor_elt, va_gc> *v = NULL;
    2437              : 
    2438         1013 :   if (vals)
    2439              :     {
    2440         1013 :       vec_alloc (v, list_length (vals));
    2441        21849 :       for (t = vals; t; t = TREE_CHAIN (t))
    2442        19823 :         CONSTRUCTOR_APPEND_ELT (v, TREE_PURPOSE (t), TREE_VALUE (t));
    2443              :     }
    2444              : 
    2445         1013 :   return build_constructor (type, v);
    2446              : }
    2447              : 
    2448              : /* Return a new CONSTRUCTOR node whose type is TYPE and whose values
    2449              :    are in a vector pointed to by VALS.  Note that the TREE_PURPOSE
    2450              :    fields in the constructor remain null.  */
    2451              : 
    2452              : tree
    2453         1691 : build_constructor_from_vec (tree type, const vec<tree, va_gc> *vals)
    2454              : {
    2455         1691 :   vec<constructor_elt, va_gc> *v = NULL;
    2456              : 
    2457        94538 :   for (tree t : vals)
    2458        92847 :     CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, t);
    2459              : 
    2460         1691 :   return build_constructor (type, v);
    2461              : }
    2462              : 
    2463              : /* Return a new CONSTRUCTOR node whose type is TYPE.  NELTS is the number
    2464              :    of elements, provided as index/value pairs.  */
    2465              : 
    2466              : tree
    2467        39955 : build_constructor_va (tree type, int nelts, ...)
    2468              : {
    2469        39955 :   vec<constructor_elt, va_gc> *v = NULL;
    2470        39955 :   va_list p;
    2471              : 
    2472        39955 :   va_start (p, nelts);
    2473        39955 :   vec_alloc (v, nelts);
    2474        39955 :   while (nelts--)
    2475              :     {
    2476       121453 :       tree index = va_arg (p, tree);
    2477       121453 :       tree value = va_arg (p, tree);
    2478       282861 :       CONSTRUCTOR_APPEND_ELT (v, index, value);
    2479              :     }
    2480        39955 :   va_end (p);
    2481        39955 :   return build_constructor (type, v);
    2482              : }
    2483              : 
    2484              : /* Return a node of type TYPE for which TREE_CLOBBER_P is true.  */
    2485              : 
    2486              : tree
    2487     10112246 : build_clobber (tree type, enum clobber_kind kind)
    2488              : {
    2489     10112246 :   tree clobber = build_constructor (type, NULL);
    2490     10112246 :   TREE_THIS_VOLATILE (clobber) = true;
    2491     10112246 :   CLOBBER_KIND (clobber) = kind;
    2492     10112246 :   return clobber;
    2493              : }
    2494              : 
    2495              : /* Return a new FIXED_CST node whose type is TYPE and value is F.  */
    2496              : 
    2497              : tree
    2498           54 : build_fixed (tree type, FIXED_VALUE_TYPE f)
    2499              : {
    2500           54 :   tree v;
    2501           54 :   FIXED_VALUE_TYPE *fp;
    2502              : 
    2503           54 :   v = make_node (FIXED_CST);
    2504           54 :   fp = ggc_alloc<fixed_value> ();
    2505           54 :   memcpy (fp, &f, sizeof (FIXED_VALUE_TYPE));
    2506              : 
    2507           54 :   TREE_TYPE (v) = type;
    2508           54 :   TREE_FIXED_CST_PTR (v) = fp;
    2509           54 :   return v;
    2510              : }
    2511              : 
    2512              : /* Return a new REAL_CST node whose type is TYPE and value is D.  */
    2513              : 
    2514              : tree
    2515     43406328 : build_real (tree type, REAL_VALUE_TYPE d)
    2516              : {
    2517     43406328 :   tree v;
    2518     43406328 :   int overflow = 0;
    2519              : 
    2520              :   /* dconst{0,1,2,m1,half} are used in various places in
    2521              :      the middle-end and optimizers, allow them here
    2522              :      even for decimal floating point types as an exception
    2523              :      by converting them to decimal.  */
    2524     43406328 :   if (DECIMAL_FLOAT_MODE_P (TYPE_MODE (type))
    2525       610797 :       && (d.cl == rvc_normal || d.cl == rvc_zero)
    2526     44014927 :       && !d.decimal)
    2527              :     {
    2528          610 :       if (memcmp (&d, &dconst1, sizeof (d)) == 0)
    2529            0 :         decimal_real_from_string (&d, "1");
    2530          610 :       else if (memcmp (&d, &dconst2, sizeof (d)) == 0)
    2531           22 :         decimal_real_from_string (&d, "2");
    2532          588 :       else if (memcmp (&d, &dconstm1, sizeof (d)) == 0)
    2533           90 :         decimal_real_from_string (&d, "-1");
    2534          498 :       else if (memcmp (&d, &dconsthalf, sizeof (d)) == 0)
    2535            0 :         decimal_real_from_string (&d, "0.5");
    2536          498 :       else if (memcmp (&d, &dconst0, sizeof (d)) == 0)
    2537              :         {
    2538              :           /* Make sure to give zero the minimum quantum exponent for
    2539              :              the type (which corresponds to all bits zero).  */
    2540          498 :           const struct real_format *fmt = REAL_MODE_FORMAT (TYPE_MODE (type));
    2541          498 :           char buf[16];
    2542          498 :           sprintf (buf, "0e%d", fmt->emin - fmt->p);
    2543          498 :           decimal_real_from_string (&d, buf);
    2544              :         }
    2545              :       else
    2546            0 :         gcc_unreachable ();
    2547              :     }
    2548              : 
    2549              :   /* ??? Used to check for overflow here via CHECK_FLOAT_TYPE.
    2550              :      Consider doing it via real_convert now.  */
    2551              : 
    2552     43406328 :   v = make_node (REAL_CST);
    2553     43406328 :   TREE_TYPE (v) = type;
    2554     43406328 :   memcpy (TREE_REAL_CST_PTR (v), &d, sizeof (REAL_VALUE_TYPE));
    2555     43406328 :   TREE_OVERFLOW (v) = overflow;
    2556     43406328 :   return v;
    2557              : }
    2558              : 
    2559              : /* Like build_real, but first truncate D to the type.  */
    2560              : 
    2561              : tree
    2562       176687 : build_real_truncate (tree type, REAL_VALUE_TYPE d)
    2563              : {
    2564       176687 :   return build_real (type, real_value_truncate (TYPE_MODE (type), d));
    2565              : }
    2566              : 
    2567              : /* Return a new REAL_CST node whose type is TYPE
    2568              :    and whose value is the integer value of the INTEGER_CST node I.  */
    2569              : 
    2570              : REAL_VALUE_TYPE
    2571     24788063 : real_value_from_int_cst (const_tree type, const_tree i)
    2572              : {
    2573     24788063 :   REAL_VALUE_TYPE d;
    2574              : 
    2575              :   /* Clear all bits of the real value type so that we can later do
    2576              :      bitwise comparisons to see if two values are the same.  */
    2577     24788063 :   memset (&d, 0, sizeof d);
    2578              : 
    2579     24788063 :   real_from_integer (&d, type ? TYPE_MODE (type) : VOIDmode, wi::to_wide (i),
    2580     24788063 :                      TYPE_SIGN (TREE_TYPE (i)));
    2581     24788063 :   return d;
    2582              : }
    2583              : 
    2584              : /* Given a tree representing an integer constant I, return a tree
    2585              :    representing the same value as a floating-point constant of type TYPE.  */
    2586              : 
    2587              : tree
    2588     24084750 : build_real_from_int_cst (tree type, const_tree i)
    2589              : {
    2590     24084750 :   tree v;
    2591     24084750 :   int overflow = TREE_OVERFLOW (i);
    2592              : 
    2593     24084750 :   v = build_real (type, real_value_from_int_cst (type, i));
    2594              : 
    2595     24084750 :   TREE_OVERFLOW (v) |= overflow;
    2596     24084750 :   return v;
    2597              : }
    2598              : 
    2599              : /* Return a new REAL_CST node whose type is TYPE
    2600              :    and whose value is the integer value I which has sign SGN.  */
    2601              : 
    2602              : tree
    2603          138 : build_real_from_wide (tree type, const wide_int_ref &i, signop sgn)
    2604              : {
    2605          138 :   REAL_VALUE_TYPE d;
    2606              : 
    2607              :   /* Clear all bits of the real value type so that we can later do
    2608              :      bitwise comparisons to see if two values are the same.  */
    2609          138 :   memset (&d, 0, sizeof d);
    2610              : 
    2611          138 :   real_from_integer (&d, TYPE_MODE (type), i, sgn);
    2612          138 :   return build_real (type, d);
    2613              : }
    2614              : 
    2615              : /* Return a newly constructed STRING_CST node whose value is the LEN
    2616              :    characters at STR when STR is nonnull, or all zeros otherwise.
    2617              :    Note that for a C string literal, LEN should include the trailing NUL.
    2618              :    The TREE_TYPE is not initialized.  */
    2619              : 
    2620              : tree
    2621    101117558 : build_string (unsigned len, const char *str /*= NULL */)
    2622              : {
    2623              :   /* Do not waste bytes provided by padding of struct tree_string.  */
    2624    101117558 :   unsigned size = len + offsetof (struct tree_string, str) + 1;
    2625              : 
    2626    101117558 :   record_node_allocation_statistics (STRING_CST, size);
    2627              : 
    2628    101117558 :   tree s = (tree) ggc_internal_alloc (size);
    2629              : 
    2630    101117558 :   memset (s, 0, sizeof (struct tree_typed));
    2631    101117558 :   TREE_SET_CODE (s, STRING_CST);
    2632    101117558 :   TREE_CONSTANT (s) = 1;
    2633    101117558 :   TREE_STRING_LENGTH (s) = len;
    2634    101117558 :   if (str)
    2635    101108391 :     memcpy (s->string.str, str, len);
    2636              :   else
    2637         9167 :     memset (s->string.str, 0, len);
    2638    101117558 :   s->string.str[len] = '\0';
    2639              : 
    2640    101117558 :   return s;
    2641              : }
    2642              : 
    2643              : /* Return a newly constructed COMPLEX_CST node whose value is
    2644              :    specified by the real and imaginary parts REAL and IMAG.
    2645              :    Both REAL and IMAG should be constant nodes.  TYPE, if specified,
    2646              :    will be the type of the COMPLEX_CST; otherwise a new type will be made.  */
    2647              : 
    2648              : tree
    2649       485439 : build_complex (tree type, tree real, tree imag)
    2650              : {
    2651       485439 :   gcc_assert (CONSTANT_CLASS_P (real));
    2652       485439 :   gcc_assert (CONSTANT_CLASS_P (imag));
    2653              : 
    2654       485439 :   tree t = make_node (COMPLEX_CST);
    2655              : 
    2656       485439 :   TREE_REALPART (t) = real;
    2657       485439 :   TREE_IMAGPART (t) = imag;
    2658       485439 :   TREE_TYPE (t) = type ? type : build_complex_type (TREE_TYPE (real));
    2659       485439 :   TREE_OVERFLOW (t) = TREE_OVERFLOW (real) | TREE_OVERFLOW (imag);
    2660       485439 :   return t;
    2661              : }
    2662              : 
    2663              : /* Build a complex (inf +- 0i), such as for the result of cproj.
    2664              :    TYPE is the complex tree type of the result.  If NEG is true, the
    2665              :    imaginary zero is negative.  */
    2666              : 
    2667              : tree
    2668          840 : build_complex_inf (tree type, bool neg)
    2669              : {
    2670          840 :   REAL_VALUE_TYPE rzero = dconst0;
    2671              : 
    2672          840 :   rzero.sign = neg;
    2673          840 :   return build_complex (type, build_real (TREE_TYPE (type), dconstinf),
    2674          840 :                         build_real (TREE_TYPE (type), rzero));
    2675              : }
    2676              : 
    2677              : /* Return the constant 1 in type TYPE.  If TYPE has several elements, each
    2678              :    element is set to 1.  In particular, this is 1 + i for complex types.  */
    2679              : 
    2680              : tree
    2681         3774 : build_each_one_cst (tree type)
    2682              : {
    2683         3774 :   if (TREE_CODE (type) == COMPLEX_TYPE)
    2684              :     {
    2685            0 :       tree scalar = build_one_cst (TREE_TYPE (type));
    2686            0 :       return build_complex (type, scalar, scalar);
    2687              :     }
    2688              :   else
    2689         3774 :     return build_one_cst (type);
    2690              : }
    2691              : 
    2692              : /* Return a constant of arithmetic type TYPE which is the
    2693              :    multiplicative identity of the set TYPE.  */
    2694              : 
    2695              : tree
    2696     10068445 : build_one_cst (tree type)
    2697              : {
    2698     10068445 :   switch (TREE_CODE (type))
    2699              :     {
    2700     10054099 :     case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE:
    2701     10054099 :     case POINTER_TYPE: case REFERENCE_TYPE:
    2702     10054099 :     case OFFSET_TYPE: case BITINT_TYPE:
    2703     10054099 :       return build_int_cst (type, 1);
    2704              : 
    2705        10730 :     case REAL_TYPE:
    2706        10730 :       return build_real (type, dconst1);
    2707              : 
    2708            0 :     case FIXED_POINT_TYPE:
    2709              :       /* We can only generate 1 for accum types.  */
    2710            0 :       gcc_assert (ALL_SCALAR_ACCUM_MODE_P (TYPE_MODE (type)));
    2711            0 :       return build_fixed (type, FCONST1 (TYPE_MODE (type)));
    2712              : 
    2713          597 :     case VECTOR_TYPE:
    2714          597 :       {
    2715          597 :         tree scalar = build_one_cst (TREE_TYPE (type));
    2716              : 
    2717          597 :         return build_vector_from_val (type, scalar);
    2718              :       }
    2719              : 
    2720         3019 :     case COMPLEX_TYPE:
    2721         6038 :       return build_complex (type,
    2722         3019 :                             build_one_cst (TREE_TYPE (type)),
    2723         6038 :                             build_zero_cst (TREE_TYPE (type)));
    2724              : 
    2725            0 :     default:
    2726            0 :       gcc_unreachable ();
    2727              :     }
    2728              : }
    2729              : 
    2730              : /* Return an integer of type TYPE containing all 1's in as much precision as
    2731              :    it contains, or a complex or vector whose subparts are such integers.  */
    2732              : 
    2733              : tree
    2734      1710356 : build_all_ones_cst (tree type)
    2735              : {
    2736      1710356 :   if (TREE_CODE (type) == COMPLEX_TYPE)
    2737              :     {
    2738            0 :       tree scalar = build_all_ones_cst (TREE_TYPE (type));
    2739            0 :       return build_complex (type, scalar, scalar);
    2740              :     }
    2741              :   else
    2742      1710356 :     return build_minus_one_cst (type);
    2743              : }
    2744              : 
    2745              : /* Return a constant of arithmetic type TYPE which is the
    2746              :    opposite of the multiplicative identity of the set TYPE.  */
    2747              : 
    2748              : tree
    2749      3134079 : build_minus_one_cst (tree type)
    2750              : {
    2751      3134079 :   switch (TREE_CODE (type))
    2752              :     {
    2753      3008602 :     case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE:
    2754      3008602 :     case POINTER_TYPE: case REFERENCE_TYPE:
    2755      3008602 :     case OFFSET_TYPE: case BITINT_TYPE:
    2756      3008602 :       return build_int_cst (type, -1);
    2757              : 
    2758        14868 :     case REAL_TYPE:
    2759        14868 :       return build_real (type, dconstm1);
    2760              : 
    2761            0 :     case FIXED_POINT_TYPE:
    2762              :       /* We can only generate 1 for accum types.  */
    2763            0 :       gcc_assert (ALL_SCALAR_ACCUM_MODE_P (TYPE_MODE (type)));
    2764            0 :       return build_fixed (type,
    2765              :                           fixed_from_double_int (double_int_minus_one,
    2766            0 :                                                  SCALAR_TYPE_MODE (type)));
    2767              : 
    2768       110609 :     case VECTOR_TYPE:
    2769       110609 :       {
    2770       110609 :         tree scalar = build_minus_one_cst (TREE_TYPE (type));
    2771              : 
    2772       110609 :         return build_vector_from_val (type, scalar);
    2773              :       }
    2774              : 
    2775            0 :     case COMPLEX_TYPE:
    2776            0 :       return build_complex (type,
    2777            0 :                             build_minus_one_cst (TREE_TYPE (type)),
    2778            0 :                             build_zero_cst (TREE_TYPE (type)));
    2779              : 
    2780            0 :     default:
    2781            0 :       gcc_unreachable ();
    2782              :     }
    2783              : }
    2784              : 
    2785              : /* Build 0 constant of type TYPE.  This is used by constructor folding
    2786              :    and thus the constant should be represented in memory by
    2787              :    zero(es).  */
    2788              : 
    2789              : tree
    2790    110442072 : build_zero_cst (tree type)
    2791              : {
    2792    110442072 :   switch (TREE_CODE (type))
    2793              :     {
    2794    109852206 :     case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE:
    2795    109852206 :     case POINTER_TYPE: case REFERENCE_TYPE:
    2796    109852206 :     case OFFSET_TYPE: case NULLPTR_TYPE: case BITINT_TYPE:
    2797    109852206 :       return build_int_cst (type, 0);
    2798              : 
    2799       222941 :     case REAL_TYPE:
    2800       222941 :       return build_real (type, dconst0);
    2801              : 
    2802            0 :     case FIXED_POINT_TYPE:
    2803            0 :       return build_fixed (type, FCONST0 (TYPE_MODE (type)));
    2804              : 
    2805       178516 :     case VECTOR_TYPE:
    2806       178516 :       {
    2807       178516 :         tree scalar = build_zero_cst (TREE_TYPE (type));
    2808              : 
    2809       178516 :         return build_vector_from_val (type, scalar);
    2810              :       }
    2811              : 
    2812         2104 :     case COMPLEX_TYPE:
    2813         2104 :       {
    2814         2104 :         tree zero = build_zero_cst (TREE_TYPE (type));
    2815              : 
    2816         2104 :         return build_complex (type, zero, zero);
    2817              :       }
    2818              : 
    2819       186305 :     default:
    2820       186305 :       if (!AGGREGATE_TYPE_P (type))
    2821            1 :         return fold_convert (type, integer_zero_node);
    2822       186304 :       return build_constructor (type, NULL);
    2823              :     }
    2824              : }
    2825              : 
    2826              : /* Build a constant of integer type TYPE, made of VALUE's bits replicated
    2827              :    every WIDTH bits to fit TYPE's precision.  */
    2828              : 
    2829              : tree
    2830           14 : build_replicated_int_cst (tree type, unsigned int width, HOST_WIDE_INT value)
    2831              : {
    2832           14 :   int n = ((TYPE_PRECISION (type) + HOST_BITS_PER_WIDE_INT - 1)
    2833           14 :            / HOST_BITS_PER_WIDE_INT);
    2834           14 :   unsigned HOST_WIDE_INT low, mask;
    2835           14 :   HOST_WIDE_INT a[WIDE_INT_MAX_INL_ELTS];
    2836           14 :   int i;
    2837              : 
    2838           14 :   gcc_assert (n && n <= WIDE_INT_MAX_INL_ELTS);
    2839              : 
    2840           14 :   if (width == HOST_BITS_PER_WIDE_INT)
    2841            0 :     low = value;
    2842              :   else
    2843              :     {
    2844           14 :       mask = (HOST_WIDE_INT_1U << width) - 1;
    2845           14 :       low = (unsigned HOST_WIDE_INT) ~0 / mask * (value & mask);
    2846              :     }
    2847              : 
    2848           28 :   for (i = 0; i < n; i++)
    2849           14 :     a[i] = low;
    2850              : 
    2851           14 :   gcc_assert (TYPE_PRECISION (type) <= MAX_BITSIZE_MODE_ANY_INT);
    2852           14 :   return wide_int_to_tree (type, wide_int::from_array (a, n,
    2853           14 :                                                        TYPE_PRECISION (type)));
    2854              : }
    2855              : 
    2856              : /* If floating-point type TYPE has an IEEE-style sign bit, return an
    2857              :    unsigned constant in which only the sign bit is set.  Return null
    2858              :    otherwise.  */
    2859              : 
    2860              : tree
    2861            0 : sign_mask_for (tree type)
    2862              : {
    2863              :   /* Avoid having to choose between a real-only sign and a pair of signs.
    2864              :      This could be relaxed if the choice becomes obvious later.  */
    2865            0 :   if (TREE_CODE (type) == COMPLEX_TYPE)
    2866              :     return NULL_TREE;
    2867              : 
    2868            0 :   auto eltmode = as_a<scalar_float_mode> (element_mode (type));
    2869            0 :   auto bits = REAL_MODE_FORMAT (eltmode)->ieee_bits;
    2870            0 :   if (!bits || !pow2p_hwi (bits))
    2871              :     return NULL_TREE;
    2872              : 
    2873            0 :   tree inttype = unsigned_type_for (type);
    2874            0 :   if (!inttype)
    2875              :     return NULL_TREE;
    2876              : 
    2877            0 :   auto mask = wi::set_bit_in_zero (bits - 1, bits);
    2878            0 :   if (VECTOR_TYPE_P (inttype))
    2879              :     {
    2880            0 :       tree elt = wide_int_to_tree (TREE_TYPE (inttype), mask);
    2881            0 :       return build_vector_from_val (inttype, elt);
    2882              :     }
    2883            0 :   return wide_int_to_tree (inttype, mask);
    2884            0 : }
    2885              : 
    2886              : /* Build a BINFO with LEN language slots.  */
    2887              : 
    2888              : tree
    2889    110484310 : make_tree_binfo (unsigned base_binfos MEM_STAT_DECL)
    2890              : {
    2891    110484310 :   tree t;
    2892    110484310 :   size_t length = (offsetof (struct tree_binfo, base_binfos)
    2893    110484310 :                    + vec<tree, va_gc>::embedded_size (base_binfos));
    2894              : 
    2895    110484310 :   record_node_allocation_statistics (TREE_BINFO, length);
    2896              : 
    2897    110484310 :   t = ggc_alloc_tree_node_stat (length PASS_MEM_STAT);
    2898              : 
    2899    110484310 :   memset (t, 0, offsetof (struct tree_binfo, base_binfos));
    2900              : 
    2901    110484310 :   TREE_SET_CODE (t, TREE_BINFO);
    2902              : 
    2903    110484310 :   BINFO_BASE_BINFOS (t)->embedded_init (base_binfos);
    2904              : 
    2905    110484310 :   return t;
    2906              : }
    2907              : 
    2908              : /* Create a CASE_LABEL_EXPR tree node and return it.  */
    2909              : 
    2910              : tree
    2911      7131926 : build_case_label (tree low_value, tree high_value, tree label_decl)
    2912              : {
    2913      7131926 :   tree t = make_node (CASE_LABEL_EXPR);
    2914              : 
    2915      7131926 :   TREE_TYPE (t) = void_type_node;
    2916      7131926 :   SET_EXPR_LOCATION (t, DECL_SOURCE_LOCATION (label_decl));
    2917              : 
    2918      7131926 :   CASE_LOW (t) = low_value;
    2919      7131926 :   CASE_HIGH (t) = high_value;
    2920      7131926 :   CASE_LABEL (t) = label_decl;
    2921      7131926 :   CASE_CHAIN (t) = NULL_TREE;
    2922              : 
    2923      7131926 :   return t;
    2924              : }
    2925              : 
    2926              : /* Build a newly constructed INTEGER_CST node.  LEN and EXT_LEN are the
    2927              :    values of TREE_INT_CST_NUNITS and TREE_INT_CST_EXT_NUNITS respectively.
    2928              :    The latter determines the length of the HOST_WIDE_INT vector.  */
    2929              : 
    2930              : tree
    2931    294554658 : make_int_cst (int len, int ext_len MEM_STAT_DECL)
    2932              : {
    2933    294554658 :   tree t;
    2934    294554658 :   int length = ((ext_len - 1) * sizeof (HOST_WIDE_INT)
    2935    294554658 :                 + sizeof (struct tree_int_cst));
    2936              : 
    2937    294554658 :   gcc_assert (len);
    2938    294554658 :   record_node_allocation_statistics (INTEGER_CST, length);
    2939              : 
    2940    294554658 :   t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
    2941              : 
    2942    294554658 :   TREE_SET_CODE (t, INTEGER_CST);
    2943    294554658 :   TREE_INT_CST_NUNITS (t) = len;
    2944    294554658 :   TREE_INT_CST_EXT_NUNITS (t) = ext_len;
    2945    294554658 :   TREE_CONSTANT (t) = 1;
    2946              : 
    2947    294554658 :   return t;
    2948              : }
    2949              : 
    2950              : /* Build a newly constructed TREE_VEC node of length LEN.  */
    2951              : 
    2952              : tree
    2953   3359739243 : make_tree_vec (int len MEM_STAT_DECL)
    2954              : {
    2955   3359739243 :   tree t;
    2956   3359739243 :   size_t length = (len - 1) * sizeof (tree) + sizeof (struct tree_vec);
    2957              : 
    2958   3359739243 :   record_node_allocation_statistics (TREE_VEC, length);
    2959              : 
    2960   3359739243 :   t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
    2961              : 
    2962   3359739243 :   TREE_SET_CODE (t, TREE_VEC);
    2963   3359739243 :   TREE_VEC_LENGTH (t) = len;
    2964              : 
    2965   3359739243 :   return t;
    2966              : }
    2967              : 
    2968              : /* Grow a TREE_VEC node to new length LEN.  */
    2969              : 
    2970              : tree
    2971       535177 : grow_tree_vec (tree v, int len MEM_STAT_DECL)
    2972              : {
    2973       535177 :   gcc_assert (TREE_CODE (v) == TREE_VEC);
    2974              : 
    2975       535177 :   int oldlen = TREE_VEC_LENGTH (v);
    2976       535177 :   gcc_assert (len > oldlen);
    2977              : 
    2978       535177 :   size_t oldlength = (oldlen - 1) * sizeof (tree) + sizeof (struct tree_vec);
    2979       535177 :   size_t length = (len - 1) * sizeof (tree) + sizeof (struct tree_vec);
    2980              : 
    2981       535177 :   record_node_allocation_statistics (TREE_VEC, length - oldlength);
    2982              : 
    2983       535177 :   v = (tree) ggc_realloc (v, length PASS_MEM_STAT);
    2984              : 
    2985       535177 :   TREE_VEC_LENGTH (v) = len;
    2986              : 
    2987       535177 :   return v;
    2988              : }
    2989              : 
    2990              : /* Return true if EXPR is the constant zero, whether it is integral, float or
    2991              :    fixed, and scalar, complex or vector.  */
    2992              : 
    2993              : bool
    2994     17837799 : zerop (const_tree expr)
    2995              : {
    2996     17837799 :   return (integer_zerop (expr)
    2997     12426533 :           || real_zerop (expr)
    2998     29869408 :           || fixed_zerop (expr));
    2999              : }
    3000              : 
    3001              : /* Return true if EXPR is the integer constant zero or a complex constant
    3002              :    of zero, or a location wrapper for such a constant.  */
    3003              : 
    3004              : bool
    3005   7053907209 : integer_zerop (const_tree expr)
    3006              : {
    3007   7053907209 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3008              : 
    3009   7053907209 :   switch (TREE_CODE (expr))
    3010              :     {
    3011   5549645357 :     case INTEGER_CST:
    3012   5549645357 :       return wi::to_wide (expr) == 0;
    3013      1201820 :     case COMPLEX_CST:
    3014      1201820 :       return (integer_zerop (TREE_REALPART (expr))
    3015      1224498 :               && integer_zerop (TREE_IMAGPART (expr)));
    3016      3154976 :     case VECTOR_CST:
    3017      3154976 :       return (VECTOR_CST_NPATTERNS (expr) == 1
    3018      2976985 :               && VECTOR_CST_DUPLICATE_P (expr)
    3019      5662676 :               && integer_zerop (VECTOR_CST_ENCODED_ELT (expr, 0)));
    3020              :     default:
    3021              :       return false;
    3022              :     }
    3023              : }
    3024              : 
    3025              : /* Return true if EXPR is the integer constant one or the corresponding
    3026              :    complex constant, or a location wrapper for such a constant.  */
    3027              : 
    3028              : bool
    3029   1089578146 : integer_onep (const_tree expr)
    3030              : {
    3031   1089578146 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3032              : 
    3033   1089578146 :   switch (TREE_CODE (expr))
    3034              :     {
    3035    943276462 :     case INTEGER_CST:
    3036    943276462 :       return wi::eq_p (wi::to_widest (expr), 1);
    3037        21757 :     case COMPLEX_CST:
    3038        21757 :       return (integer_onep (TREE_REALPART (expr))
    3039        21809 :               && integer_zerop (TREE_IMAGPART (expr)));
    3040       204264 :     case VECTOR_CST:
    3041       204264 :       return (VECTOR_CST_NPATTERNS (expr) == 1
    3042       181426 :               && VECTOR_CST_DUPLICATE_P (expr)
    3043       361326 :               && integer_onep (VECTOR_CST_ENCODED_ELT (expr, 0)));
    3044              :     default:
    3045              :       return false;
    3046              :     }
    3047              : }
    3048              : 
    3049              : /* Return true if EXPR is the integer constant one.  For complex and vector,
    3050              :    return true if every piece is the integer constant one.
    3051              :    Also return true for location wrappers for such a constant.  */
    3052              : 
    3053              : bool
    3054       768894 : integer_each_onep (const_tree expr)
    3055              : {
    3056       768894 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3057              : 
    3058       768894 :   if (TREE_CODE (expr) == COMPLEX_CST)
    3059           34 :     return (integer_onep (TREE_REALPART (expr))
    3060           48 :             && integer_onep (TREE_IMAGPART (expr)));
    3061              :   else
    3062       768860 :     return integer_onep (expr);
    3063              : }
    3064              : 
    3065              : /* Return true if EXPR is an integer containing all 1's in as much precision
    3066              :    as it contains, or a complex or vector whose subparts are such integers,
    3067              :    or a location wrapper for such a constant.  */
    3068              : 
    3069              : bool
    3070    300647041 : integer_all_onesp (const_tree expr)
    3071              : {
    3072    300647041 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3073              : 
    3074    300647041 :   if (TREE_CODE (expr) == COMPLEX_CST
    3075          937 :       && integer_all_onesp (TREE_REALPART (expr))
    3076    300647081 :       && integer_all_onesp (TREE_IMAGPART (expr)))
    3077              :     return true;
    3078              : 
    3079    300647005 :   else if (TREE_CODE (expr) == VECTOR_CST)
    3080       635905 :     return (VECTOR_CST_NPATTERNS (expr) == 1
    3081       581347 :             && VECTOR_CST_DUPLICATE_P (expr)
    3082      1192037 :             && integer_all_onesp (VECTOR_CST_ENCODED_ELT (expr, 0)));
    3083              : 
    3084    300011100 :   else if (TREE_CODE (expr) != INTEGER_CST)
    3085              :     return false;
    3086              : 
    3087    199451377 :   return (wi::max_value (TYPE_PRECISION (TREE_TYPE (expr)), UNSIGNED)
    3088    398968870 :           == wi::to_wide (expr));
    3089              : }
    3090              : 
    3091              : /* Return true if EXPR is the integer constant minus one, or a location
    3092              :    wrapper for such a constant.  */
    3093              : 
    3094              : bool
    3095    218589214 : integer_minus_onep (const_tree expr)
    3096              : {
    3097    218589214 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3098              : 
    3099    218589214 :   if (TREE_CODE (expr) == COMPLEX_CST)
    3100         9421 :     return (integer_all_onesp (TREE_REALPART (expr))
    3101         9425 :             && integer_zerop (TREE_IMAGPART (expr)));
    3102              :   else
    3103    218579793 :     return integer_all_onesp (expr);
    3104              : }
    3105              : 
    3106              : /* Return true if EXPR is an integer constant that is a power of 2 (i.e., has
    3107              :    only one bit on), or a location wrapper for such a constant.  */
    3108              : 
    3109              : bool
    3110     22462528 : integer_pow2p (const_tree expr)
    3111              : {
    3112     22462528 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3113              : 
    3114     22462528 :   if (TREE_CODE (expr) == COMPLEX_CST
    3115          567 :       && integer_pow2p (TREE_REALPART (expr))
    3116     22462769 :       && integer_zerop (TREE_IMAGPART (expr)))
    3117              :     return true;
    3118              : 
    3119     22462361 :   if (TREE_CODE (expr) != INTEGER_CST)
    3120              :     return false;
    3121              : 
    3122     14086537 :   return wi::popcount (wi::to_wide (expr)) == 1;
    3123              : }
    3124              : 
    3125              : /* Return true if EXPR is an integer constant other than zero or a
    3126              :    complex constant other than zero, or a location wrapper for such a
    3127              :    constant.  */
    3128              : 
    3129              : bool
    3130    164433936 : integer_nonzerop (const_tree expr)
    3131              : {
    3132    164433936 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3133              : 
    3134    164433936 :   return ((TREE_CODE (expr) == INTEGER_CST
    3135     86550815 :            && wi::to_wide (expr) != 0)
    3136    193689564 :           || (TREE_CODE (expr) == COMPLEX_CST
    3137          244 :               && (integer_nonzerop (TREE_REALPART (expr))
    3138          184 :                   || integer_nonzerop (TREE_IMAGPART (expr)))));
    3139              : }
    3140              : 
    3141              : /* Return true if EXPR is the integer constant one.  For vector,
    3142              :    return true if every piece is the integer constant minus one
    3143              :    (representing the value TRUE).
    3144              :    Also return true for location wrappers for such a constant.  */
    3145              : 
    3146              : bool
    3147      1178545 : integer_truep (const_tree expr)
    3148              : {
    3149      1178545 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3150              : 
    3151      1178545 :   if (TREE_CODE (expr) == VECTOR_CST)
    3152        15313 :     return integer_all_onesp (expr);
    3153      1163232 :   return integer_onep (expr);
    3154              : }
    3155              : 
    3156              : /* Return true if EXPR is the fixed-point constant zero, or a location wrapper
    3157              :    for such a constant.  */
    3158              : 
    3159              : bool
    3160     29400273 : fixed_zerop (const_tree expr)
    3161              : {
    3162     29400273 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3163              : 
    3164     29400273 :   return (TREE_CODE (expr) == FIXED_CST
    3165     29400273 :           && TREE_FIXED_CST (expr).data.is_zero ());
    3166              : }
    3167              : 
    3168              : /* Return the power of two represented by a tree node known to be a
    3169              :    power of two.  */
    3170              : 
    3171              : int
    3172       785739 : tree_log2 (const_tree expr)
    3173              : {
    3174       785739 :   if (TREE_CODE (expr) == COMPLEX_CST)
    3175            0 :     return tree_log2 (TREE_REALPART (expr));
    3176              : 
    3177       785739 :   return wi::exact_log2 (wi::to_wide (expr));
    3178              : }
    3179              : 
    3180              : /* Similar, but return the largest integer Y such that 2 ** Y is less
    3181              :    than or equal to EXPR.  */
    3182              : 
    3183              : int
    3184      2912102 : tree_floor_log2 (const_tree expr)
    3185              : {
    3186      2912102 :   if (TREE_CODE (expr) == COMPLEX_CST)
    3187            0 :     return tree_log2 (TREE_REALPART (expr));
    3188              : 
    3189      2912102 :   return wi::floor_log2 (wi::to_wide (expr));
    3190              : }
    3191              : 
    3192              : /* Return number of known trailing zero bits in EXPR, or, if the value of
    3193              :    EXPR is known to be zero, the precision of it's type.  */
    3194              : 
    3195              : unsigned int
    3196     85028199 : tree_ctz (const_tree expr)
    3197              : {
    3198    170054688 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (expr))
    3199     85036278 :       && !POINTER_TYPE_P (TREE_TYPE (expr)))
    3200              :     return 0;
    3201              : 
    3202     85028136 :   unsigned int ret1, ret2, prec = TYPE_PRECISION (TREE_TYPE (expr));
    3203     85028136 :   switch (TREE_CODE (expr))
    3204              :     {
    3205     45083577 :     case INTEGER_CST:
    3206     45083577 :       ret1 = wi::ctz (wi::to_wide (expr));
    3207     45083577 :       return MIN (ret1, prec);
    3208     13043122 :     case SSA_NAME:
    3209     13043122 :       ret1 = wi::ctz (get_nonzero_bits (expr));
    3210     13043122 :       return MIN (ret1, prec);
    3211      2086835 :     case PLUS_EXPR:
    3212      2086835 :     case MINUS_EXPR:
    3213      2086835 :     case BIT_IOR_EXPR:
    3214      2086835 :     case BIT_XOR_EXPR:
    3215      2086835 :     case MIN_EXPR:
    3216      2086835 :     case MAX_EXPR:
    3217      2086835 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3218      2086835 :       if (ret1 == 0)
    3219              :         return ret1;
    3220       952269 :       ret2 = tree_ctz (TREE_OPERAND (expr, 1));
    3221       952269 :       return MIN (ret1, ret2);
    3222            0 :     case POINTER_PLUS_EXPR:
    3223            0 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3224            0 :       ret2 = tree_ctz (TREE_OPERAND (expr, 1));
    3225              :       /* Second operand is sizetype, which could be in theory
    3226              :          wider than pointer's precision.  Make sure we never
    3227              :          return more than prec.  */
    3228            0 :       ret2 = MIN (ret2, prec);
    3229            0 :       return MIN (ret1, ret2);
    3230          237 :     case BIT_AND_EXPR:
    3231          237 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3232          237 :       ret2 = tree_ctz (TREE_OPERAND (expr, 1));
    3233          237 :       return MAX (ret1, ret2);
    3234     12091669 :     case MULT_EXPR:
    3235     12091669 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3236     12091669 :       ret2 = tree_ctz (TREE_OPERAND (expr, 1));
    3237     12091669 :       return MIN (ret1 + ret2, prec);
    3238            0 :     case LSHIFT_EXPR:
    3239            0 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3240            0 :       if (tree_fits_uhwi_p (TREE_OPERAND (expr, 1))
    3241            0 :           && (tree_to_uhwi (TREE_OPERAND (expr, 1)) < prec))
    3242              :         {
    3243            0 :           ret2 = tree_to_uhwi (TREE_OPERAND (expr, 1));
    3244            0 :           return MIN (ret1 + ret2, prec);
    3245              :         }
    3246              :       return ret1;
    3247            0 :     case RSHIFT_EXPR:
    3248            0 :       if (tree_fits_uhwi_p (TREE_OPERAND (expr, 1))
    3249            0 :           && (tree_to_uhwi (TREE_OPERAND (expr, 1)) < prec))
    3250              :         {
    3251            0 :           ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3252            0 :           ret2 = tree_to_uhwi (TREE_OPERAND (expr, 1));
    3253            0 :           if (ret1 > ret2)
    3254            0 :             return ret1 - ret2;
    3255              :         }
    3256              :       return 0;
    3257         6093 :     case TRUNC_DIV_EXPR:
    3258         6093 :     case CEIL_DIV_EXPR:
    3259         6093 :     case FLOOR_DIV_EXPR:
    3260         6093 :     case ROUND_DIV_EXPR:
    3261         6093 :     case EXACT_DIV_EXPR:
    3262         6093 :       if (TREE_CODE (TREE_OPERAND (expr, 1)) == INTEGER_CST
    3263         6093 :           && tree_int_cst_sgn (TREE_OPERAND (expr, 1)) == 1)
    3264              :         {
    3265         6093 :           int l = tree_log2 (TREE_OPERAND (expr, 1));
    3266         6093 :           if (l >= 0)
    3267              :             {
    3268         5005 :               ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3269         5005 :               ret2 = l;
    3270         5005 :               if (ret1 > ret2)
    3271            0 :                 return ret1 - ret2;
    3272              :             }
    3273              :         }
    3274              :       return 0;
    3275     12693185 :     CASE_CONVERT:
    3276     12693185 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3277     12693185 :       if (ret1 && ret1 == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (expr, 0))))
    3278              :         ret1 = prec;
    3279     12693185 :       return MIN (ret1, prec);
    3280            0 :     case SAVE_EXPR:
    3281            0 :       return tree_ctz (TREE_OPERAND (expr, 0));
    3282        12845 :     case COND_EXPR:
    3283        12845 :       ret1 = tree_ctz (TREE_OPERAND (expr, 1));
    3284        12845 :       if (ret1 == 0)
    3285              :         return 0;
    3286          205 :       ret2 = tree_ctz (TREE_OPERAND (expr, 2));
    3287          205 :       return MIN (ret1, ret2);
    3288            0 :     case COMPOUND_EXPR:
    3289            0 :       return tree_ctz (TREE_OPERAND (expr, 1));
    3290          196 :     case ADDR_EXPR:
    3291          196 :       ret1 = get_pointer_alignment (const_cast<tree> (expr));
    3292          196 :       if (ret1 > BITS_PER_UNIT)
    3293              :         {
    3294          196 :           ret1 = ctz_hwi (ret1 / BITS_PER_UNIT);
    3295          196 :           return MIN (ret1, prec);
    3296              :         }
    3297              :       return 0;
    3298              :     default:
    3299              :       return 0;
    3300              :     }
    3301              : }
    3302              : 
    3303              : /* Return true if EXPR is the real constant zero.  Trailing zeroes matter for
    3304              :    decimal float constants, so don't return true for them.
    3305              :    Also return true for location wrappers around such a constant.  */
    3306              : 
    3307              : bool
    3308    600214231 : real_zerop (const_tree expr)
    3309              : {
    3310    600214231 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3311              : 
    3312    600214231 :   switch (TREE_CODE (expr))
    3313              :     {
    3314     19864225 :     case REAL_CST:
    3315     19864225 :       return real_equal (&TREE_REAL_CST (expr), &dconst0)
    3316     19864225 :              && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr))));
    3317        46198 :     case COMPLEX_CST:
    3318        46198 :       return real_zerop (TREE_REALPART (expr))
    3319        59814 :              && real_zerop (TREE_IMAGPART (expr));
    3320       525281 :     case VECTOR_CST:
    3321       525281 :       {
    3322              :         /* Don't simply check for a duplicate because the predicate
    3323              :            accepts both +0.0 and -0.0.  */
    3324       525281 :         unsigned count = vector_cst_encoded_nelts (expr);
    3325      1089056 :         for (unsigned int i = 0; i < count; ++i)
    3326       538218 :           if (!real_zerop (VECTOR_CST_ENCODED_ELT (expr, i)))
    3327              :             return false;
    3328              :         return true;
    3329              :       }
    3330              :     default:
    3331              :       return false;
    3332              :     }
    3333              : }
    3334              : 
    3335              : /* Return true if EXPR is the real constant negative zero.  */
    3336              : 
    3337              : bool
    3338            6 : real_negzerop (const_tree expr)
    3339              : {
    3340            6 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3341              : 
    3342            6 :   if (TREE_CODE (expr) == VECTOR_CST)
    3343              :     {
    3344            0 :       expr = uniform_vector_p (expr);
    3345            0 :       if (!expr)
    3346              :         return false;
    3347              :     }
    3348              : 
    3349            6 :   if (TREE_CODE (expr) == COMPLEX_CST)
    3350            2 :     return real_negzerop (TREE_REALPART (expr))
    3351            4 :            && real_negzerop (TREE_IMAGPART (expr));
    3352              : 
    3353            4 :   return TREE_CODE (expr) == REAL_CST
    3354            4 :           && REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (expr))
    3355            8 :           && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr))));
    3356              : }
    3357              : 
    3358              : /* Return true if EXPR is the real constant one in real or complex form.
    3359              :    Trailing zeroes matter for decimal float constants, so don't return
    3360              :    true for them.
    3361              :    Also return true for location wrappers around such a constant.  */
    3362              : 
    3363              : bool
    3364    122385571 : real_onep (const_tree expr)
    3365              : {
    3366    122385571 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3367              : 
    3368    122385571 :   switch (TREE_CODE (expr))
    3369              :     {
    3370      7219515 :     case REAL_CST:
    3371      7219515 :       return real_equal (&TREE_REAL_CST (expr), &dconst1)
    3372      7219515 :              && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr))));
    3373        12972 :     case COMPLEX_CST:
    3374        12972 :       return real_onep (TREE_REALPART (expr))
    3375        16581 :              && real_zerop (TREE_IMAGPART (expr));
    3376        63777 :     case VECTOR_CST:
    3377        63777 :       return (VECTOR_CST_NPATTERNS (expr) == 1
    3378        54624 :               && VECTOR_CST_DUPLICATE_P (expr)
    3379       107736 :               && real_onep (VECTOR_CST_ENCODED_ELT (expr, 0)));
    3380              :     default:
    3381              :       return false;
    3382              :     }
    3383              : }
    3384              : 
    3385              : /* Return true if EXPR is the real constant minus one.  Trailing zeroes
    3386              :    matter for decimal float constants, so don't return true for them.
    3387              :    Also return true for location wrappers around such a constant.  */
    3388              : 
    3389              : bool
    3390    123431835 : real_minus_onep (const_tree expr)
    3391              : {
    3392    123431835 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3393              : 
    3394    123431835 :   switch (TREE_CODE (expr))
    3395              :     {
    3396      7152873 :     case REAL_CST:
    3397      7152873 :       return real_equal (&TREE_REAL_CST (expr), &dconstm1)
    3398      7152873 :              && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr))));
    3399        12952 :     case COMPLEX_CST:
    3400        12952 :       return real_minus_onep (TREE_REALPART (expr))
    3401        15324 :              && real_zerop (TREE_IMAGPART (expr));
    3402        65733 :     case VECTOR_CST:
    3403        65733 :       return (VECTOR_CST_NPATTERNS (expr) == 1
    3404        55981 :               && VECTOR_CST_DUPLICATE_P (expr)
    3405       110868 :               && real_minus_onep (VECTOR_CST_ENCODED_ELT (expr, 0)));
    3406              :     default:
    3407              :       return false;
    3408              :     }
    3409              : }
    3410              : 
    3411              : /* Return true if T could be a floating point zero.  */
    3412              : 
    3413              : bool
    3414       712656 : real_maybe_zerop (const_tree expr)
    3415              : {
    3416       712656 :   switch (TREE_CODE (expr))
    3417              :     {
    3418       486116 :     case REAL_CST:
    3419              :       /* Can't use real_zerop here, as it always returns false for decimal
    3420              :          floats.  And can't use TREE_REAL_CST (expr).cl == rvc_zero
    3421              :          either, as decimal zeros are rvc_normal.  */
    3422       486116 :       return real_equal (&TREE_REAL_CST (expr), &dconst0);
    3423            0 :     case COMPLEX_CST:
    3424            0 :       return (real_maybe_zerop (TREE_REALPART (expr))
    3425            0 :               || real_maybe_zerop (TREE_IMAGPART (expr)));
    3426            0 :     case VECTOR_CST:
    3427            0 :       {
    3428            0 :         unsigned count = vector_cst_encoded_nelts (expr);
    3429            0 :         for (unsigned int i = 0; i < count; ++i)
    3430            0 :           if (real_maybe_zerop (VECTOR_CST_ENCODED_ELT (expr, i)))
    3431              :             return true;
    3432              :         return false;
    3433              :       }
    3434              :     default:
    3435              :       /* Perhaps for SSA_NAMEs we could query frange.  */
    3436              :       return true;
    3437              :     }
    3438              : }
    3439              : 
    3440              : /* True if EXP is a constant or a cast of a constant.  */
    3441              : 
    3442              : bool
    3443         6484 : really_constant_p (const_tree exp)
    3444              : {
    3445              :   /* This is not quite the same as STRIP_NOPS.  It does more.  */
    3446        12976 :   while (CONVERT_EXPR_P (exp)
    3447        13133 :          || TREE_CODE (exp) == NON_LVALUE_EXPR)
    3448          165 :     exp = TREE_OPERAND (exp, 0);
    3449         6484 :   return TREE_CONSTANT (exp);
    3450              : }
    3451              : 
    3452              : /* Return true if T holds a polynomial pointer difference, storing it in
    3453              :    *VALUE if so.  A true return means that T's precision is no greater
    3454              :    than 64 bits, which is the largest address space we support, so *VALUE
    3455              :    never loses precision.  However, the signedness of the result does
    3456              :    not necessarily match the signedness of T: sometimes an unsigned type
    3457              :    like sizetype is used to encode a value that is actually negative.  */
    3458              : 
    3459              : bool
    3460     11371667 : ptrdiff_tree_p (const_tree t, poly_int64 *value)
    3461              : {
    3462     11371667 :   if (!t)
    3463              :     return false;
    3464     11371667 :   if (TREE_CODE (t) == INTEGER_CST)
    3465              :     {
    3466      3233190 :       if (!cst_and_fits_in_hwi (t))
    3467              :         return false;
    3468      3232325 :       *value = int_cst_value (t);
    3469      3232325 :       return true;
    3470              :     }
    3471              :   if (POLY_INT_CST_P (t))
    3472              :     {
    3473              :       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    3474              :         if (!cst_and_fits_in_hwi (POLY_INT_CST_COEFF (t, i)))
    3475              :           return false;
    3476              :       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    3477              :         value->coeffs[i] = int_cst_value (POLY_INT_CST_COEFF (t, i));
    3478              :       return true;
    3479              :     }
    3480              :   return false;
    3481              : }
    3482              : 
    3483              : poly_int64
    3484    487556028 : tree_to_poly_int64 (const_tree t)
    3485              : {
    3486    487556028 :   gcc_assert (tree_fits_poly_int64_p (t));
    3487    487556028 :   if (POLY_INT_CST_P (t))
    3488              :     return poly_int_cst_value (t).force_shwi ();
    3489    487556028 :   return TREE_INT_CST_LOW (t);
    3490              : }
    3491              : 
    3492              : poly_uint64
    3493    545880723 : tree_to_poly_uint64 (const_tree t)
    3494              : {
    3495    545880723 :   gcc_assert (tree_fits_poly_uint64_p (t));
    3496    545880723 :   if (POLY_INT_CST_P (t))
    3497              :     return poly_int_cst_value (t).force_uhwi ();
    3498    545880723 :   return TREE_INT_CST_LOW (t);
    3499              : }
    3500              : 
    3501              : /* Return first list element whose TREE_VALUE is ELEM.
    3502              :    Return 0 if ELEM is not in LIST.  */
    3503              : 
    3504              : tree
    3505      8063002 : value_member (tree elem, tree list)
    3506              : {
    3507     23487951 :   while (list)
    3508              :     {
    3509     20416346 :       if (elem == TREE_VALUE (list))
    3510              :         return list;
    3511     15424949 :       list = TREE_CHAIN (list);
    3512              :     }
    3513              :   return NULL_TREE;
    3514              : }
    3515              : 
    3516              : /* Return first list element whose TREE_PURPOSE is ELEM.
    3517              :    Return 0 if ELEM is not in LIST.  */
    3518              : 
    3519              : tree
    3520    205676521 : purpose_member (const_tree elem, tree list)
    3521              : {
    3522    543672601 :   while (list)
    3523              :     {
    3524    370756009 :       if (elem == TREE_PURPOSE (list))
    3525              :         return list;
    3526    337996080 :       list = TREE_CHAIN (list);
    3527              :     }
    3528              :   return NULL_TREE;
    3529              : }
    3530              : 
    3531              : /* Return true if ELEM is in V.  */
    3532              : 
    3533              : bool
    3534      5292507 : vec_member (const_tree elem, vec<tree, va_gc> *v)
    3535              : {
    3536      5292507 :   unsigned ix;
    3537      5292507 :   tree t;
    3538      7998431 :   FOR_EACH_VEC_SAFE_ELT (v, ix, t)
    3539      2714201 :     if (elem == t)
    3540              :       return true;
    3541              :   return false;
    3542              : }
    3543              : 
    3544              : /* Returns element number IDX (zero-origin) of chain CHAIN, or
    3545              :    NULL_TREE.  */
    3546              : 
    3547              : tree
    3548     22895299 : chain_index (int idx, tree chain)
    3549              : {
    3550     29377320 :   for (; chain && idx > 0; --idx)
    3551      6482021 :     chain = TREE_CHAIN (chain);
    3552     22895299 :   return chain;
    3553              : }
    3554              : 
    3555              : /* Return true if ELEM is part of the chain CHAIN.  */
    3556              : 
    3557              : bool
    3558       230802 : chain_member (const_tree elem, const_tree chain)
    3559              : {
    3560       425362 :   while (chain)
    3561              :     {
    3562       423877 :       if (elem == chain)
    3563              :         return true;
    3564       194560 :       chain = DECL_CHAIN (chain);
    3565              :     }
    3566              : 
    3567              :   return false;
    3568              : }
    3569              : 
    3570              : /* Return the length of a chain of nodes chained through TREE_CHAIN.
    3571              :    We expect a null pointer to mark the end of the chain.
    3572              :    This is the Lisp primitive `length'.  */
    3573              : 
    3574              : int
    3575   2179389400 : list_length (const_tree t)
    3576              : {
    3577   2179389400 :   const_tree p = t;
    3578              : #ifdef ENABLE_TREE_CHECKING
    3579   2179389400 :   const_tree q = t;
    3580              : #endif
    3581   2179389400 :   int len = 0;
    3582              : 
    3583   3628066068 :   while (p)
    3584              :     {
    3585   1448676668 :       p = TREE_CHAIN (p);
    3586              : #ifdef ENABLE_TREE_CHECKING
    3587   1448676668 :       if (len % 2)
    3588    471637801 :         q = TREE_CHAIN (q);
    3589   1448676668 :       gcc_assert (p != q);
    3590              : #endif
    3591   1448676668 :       len++;
    3592              :     }
    3593              : 
    3594   2179389400 :   return len;
    3595              : }
    3596              : 
    3597              : /* Returns the first FIELD_DECL in the TYPE_FIELDS of the RECORD_TYPE or
    3598              :    UNION_TYPE TYPE, or NULL_TREE if none.  */
    3599              : 
    3600              : tree
    3601       160326 : first_field (const_tree type)
    3602              : {
    3603       160326 :   tree t = TYPE_FIELDS (type);
    3604      4321536 :   while (t && TREE_CODE (t) != FIELD_DECL)
    3605      4161210 :     t = TREE_CHAIN (t);
    3606       160326 :   return t;
    3607              : }
    3608              : 
    3609              : /* Returns the last FIELD_DECL in the TYPE_FIELDS of the RECORD_TYPE or
    3610              :    UNION_TYPE TYPE, or NULL_TREE if none.  */
    3611              : 
    3612              : tree
    3613      2845119 : last_field (const_tree type)
    3614              : {
    3615      2845119 :   tree last = NULL_TREE;
    3616              : 
    3617     64174384 :   for (tree fld = TYPE_FIELDS (type); fld; fld = TREE_CHAIN (fld))
    3618              :     {
    3619     61329265 :       if (TREE_CODE (fld) != FIELD_DECL)
    3620     52761288 :         continue;
    3621              : 
    3622              :       last = fld;
    3623              :     }
    3624              : 
    3625      2845119 :   return last;
    3626              : }
    3627              : 
    3628              : /* Concatenate two chains of nodes (chained through TREE_CHAIN)
    3629              :    by modifying the last node in chain 1 to point to chain 2.
    3630              :    This is the Lisp primitive `nconc'.  */
    3631              : 
    3632              : tree
    3633   4229791926 : chainon (tree op1, tree op2)
    3634              : {
    3635   4229791926 :   tree t1;
    3636              : 
    3637   4229791926 :   if (!op1)
    3638              :     return op2;
    3639    779256003 :   if (!op2)
    3640              :     return op1;
    3641              : 
    3642   1600602829 :   for (t1 = op1; TREE_CHAIN (t1); t1 = TREE_CHAIN (t1))
    3643    901369163 :     continue;
    3644    699233666 :   TREE_CHAIN (t1) = op2;
    3645              : 
    3646              : #ifdef ENABLE_TREE_CHECKING
    3647    699233666 :   {
    3648    699233666 :     tree t2;
    3649   1784255143 :     for (t2 = op2; t2; t2 = TREE_CHAIN (t2))
    3650   1085021477 :       gcc_assert (t2 != t1);
    3651              :   }
    3652              : #endif
    3653              : 
    3654              :   return op1;
    3655    901369163 : }
    3656              : 
    3657              : /* Return the last node in a chain of nodes (chained through TREE_CHAIN).  */
    3658              : 
    3659              : tree
    3660    105346450 : tree_last (tree chain)
    3661              : {
    3662    105346450 :   tree next;
    3663    105346450 :   if (chain)
    3664    192631523 :     while ((next = TREE_CHAIN (chain)))
    3665              :       chain = next;
    3666    105346450 :   return chain;
    3667              : }
    3668              : 
    3669              : /* Reverse the order of elements in the chain T,
    3670              :    and return the new head of the chain (old last element).  */
    3671              : 
    3672              : tree
    3673   1584591163 : nreverse (tree t)
    3674              : {
    3675   1584591163 :   tree prev = 0, decl, next;
    3676   4003756622 :   for (decl = t; decl; decl = next)
    3677              :     {
    3678              :       /* We shouldn't be using this function to reverse BLOCK chains; we
    3679              :          have blocks_nreverse for that.  */
    3680   2419165459 :       gcc_checking_assert (TREE_CODE (decl) != BLOCK);
    3681   2419165459 :       next = TREE_CHAIN (decl);
    3682   2419165459 :       TREE_CHAIN (decl) = prev;
    3683   2419165459 :       prev = decl;
    3684              :     }
    3685   1584591163 :   return prev;
    3686              : }
    3687              : 
    3688              : /* Return a newly created TREE_LIST node whose
    3689              :    purpose and value fields are PARM and VALUE.  */
    3690              : 
    3691              : tree
    3692   1471649781 : build_tree_list (tree parm, tree value MEM_STAT_DECL)
    3693              : {
    3694   1471649781 :   tree t = make_node (TREE_LIST PASS_MEM_STAT);
    3695   1471649781 :   TREE_PURPOSE (t) = parm;
    3696   1471649781 :   TREE_VALUE (t) = value;
    3697   1471649781 :   return t;
    3698              : }
    3699              : 
    3700              : /* Build a chain of TREE_LIST nodes from a vector.  */
    3701              : 
    3702              : tree
    3703     92782033 : build_tree_list_vec (const vec<tree, va_gc> *vec MEM_STAT_DECL)
    3704              : {
    3705     92782033 :   tree ret = NULL_TREE;
    3706     92782033 :   tree *pp = &ret;
    3707     92782033 :   unsigned int i;
    3708     92782033 :   tree t;
    3709    194764879 :   FOR_EACH_VEC_SAFE_ELT (vec, i, t)
    3710              :     {
    3711    101982846 :       *pp = build_tree_list (NULL, t PASS_MEM_STAT);
    3712    101982846 :       pp = &TREE_CHAIN (*pp);
    3713              :     }
    3714     92782033 :   return ret;
    3715              : }
    3716              : 
    3717              : /* Return a newly created TREE_LIST node whose
    3718              :    purpose and value fields are PURPOSE and VALUE
    3719              :    and whose TREE_CHAIN is CHAIN.  */
    3720              : 
    3721              : tree
    3722   5682542199 : tree_cons (tree purpose, tree value, tree chain MEM_STAT_DECL)
    3723              : {
    3724   5682542199 :   tree node;
    3725              : 
    3726   5682542199 :   node = ggc_alloc_tree_node_stat (sizeof (struct tree_list) PASS_MEM_STAT);
    3727   5682542199 :   memset (node, 0, sizeof (struct tree_common));
    3728              : 
    3729   5682542199 :   record_node_allocation_statistics (TREE_LIST, sizeof (struct tree_list));
    3730              : 
    3731   5682542199 :   TREE_SET_CODE (node, TREE_LIST);
    3732   5682542199 :   TREE_CHAIN (node) = chain;
    3733   5682542199 :   TREE_PURPOSE (node) = purpose;
    3734   5682542199 :   TREE_VALUE (node) = value;
    3735   5682542199 :   return node;
    3736              : }
    3737              : 
    3738              : /* Return the values of the elements of a CONSTRUCTOR as a vector of
    3739              :    trees.  */
    3740              : 
    3741              : vec<tree, va_gc> *
    3742            0 : ctor_to_vec (tree ctor)
    3743              : {
    3744            0 :   vec<tree, va_gc> *vec;
    3745            0 :   vec_alloc (vec, CONSTRUCTOR_NELTS (ctor));
    3746            0 :   unsigned int ix;
    3747            0 :   tree val;
    3748              : 
    3749            0 :   FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (ctor), ix, val)
    3750            0 :     vec->quick_push (val);
    3751              : 
    3752            0 :   return vec;
    3753              : }
    3754              : 
    3755              : /* Return the size nominally occupied by an object of type TYPE
    3756              :    when it resides in memory.  The value is measured in units of bytes,
    3757              :    and its data type is that normally used for type sizes
    3758              :    (which is the first type created by make_signed_type or
    3759              :    make_unsigned_type).  */
    3760              : 
    3761              : tree
    3762     29050619 : size_in_bytes_loc (location_t loc, const_tree type)
    3763              : {
    3764     29050619 :   tree t;
    3765              : 
    3766     29050619 :   if (type == error_mark_node)
    3767            0 :     return integer_zero_node;
    3768              : 
    3769     29050619 :   type = TYPE_MAIN_VARIANT (type);
    3770     29050619 :   t = TYPE_SIZE_UNIT (type);
    3771              : 
    3772     29050619 :   if (t == 0)
    3773              :     {
    3774           65 :       lang_hooks.types.incomplete_type_error (loc, NULL_TREE, type);
    3775           65 :       return size_zero_node;
    3776              :     }
    3777              : 
    3778              :   return t;
    3779              : }
    3780              : 
    3781              : /* Return the size of TYPE (in bytes) as a wide integer
    3782              :    or return -1 if the size can vary or is larger than an integer.  */
    3783              : 
    3784              : HOST_WIDE_INT
    3785    515057820 : int_size_in_bytes (const_tree type)
    3786              : {
    3787    515057820 :   tree t;
    3788              : 
    3789    515057820 :   if (type == error_mark_node)
    3790              :     return 0;
    3791              : 
    3792    515057820 :   type = TYPE_MAIN_VARIANT (type);
    3793    515057820 :   t = TYPE_SIZE_UNIT (type);
    3794              : 
    3795    515057820 :   if (t && tree_fits_uhwi_p (t))
    3796    515003540 :     return TREE_INT_CST_LOW (t);
    3797              :   else
    3798              :     return -1;
    3799              : }
    3800              : 
    3801              : /* Return the maximum size of TYPE (in bytes) as a wide integer
    3802              :    or return -1 if the size can vary or is larger than an integer.  */
    3803              : 
    3804              : HOST_WIDE_INT
    3805         9298 : max_int_size_in_bytes (const_tree type)
    3806              : {
    3807         9298 :   HOST_WIDE_INT size = -1;
    3808         9298 :   tree size_tree;
    3809              : 
    3810              :   /* If this is an array type, check for a possible MAX_SIZE attached.  */
    3811              : 
    3812         9298 :   if (TREE_CODE (type) == ARRAY_TYPE)
    3813              :     {
    3814         8565 :       size_tree = TYPE_ARRAY_MAX_SIZE (type);
    3815              : 
    3816         8565 :       if (size_tree && tree_fits_uhwi_p (size_tree))
    3817            0 :         size = tree_to_uhwi (size_tree);
    3818              :     }
    3819              : 
    3820              :   /* If we still haven't been able to get a size, see if the language
    3821              :      can compute a maximum size.  */
    3822              : 
    3823            0 :   if (size == -1)
    3824              :     {
    3825         9298 :       size_tree = lang_hooks.types.max_size (type);
    3826              : 
    3827         9298 :       if (size_tree && tree_fits_uhwi_p (size_tree))
    3828            0 :         size = tree_to_uhwi (size_tree);
    3829              :     }
    3830              : 
    3831         9298 :   return size;
    3832              : }
    3833              : 
    3834              : /* Return the bit position of FIELD, in bits from the start of the record.
    3835              :    This is a tree of type bitsizetype.  */
    3836              : 
    3837              : tree
    3838    146550410 : bit_position (const_tree field)
    3839              : {
    3840    146550410 :   return bit_from_pos (DECL_FIELD_OFFSET (field),
    3841    146550410 :                        DECL_FIELD_BIT_OFFSET (field));
    3842              : }
    3843              : 
    3844              : /* Return the byte position of FIELD, in bytes from the start of the record.
    3845              :    This is a tree of type sizetype.  */
    3846              : 
    3847              : tree
    3848    119990988 : byte_position (const_tree field)
    3849              : {
    3850    119990988 :   return byte_from_pos (DECL_FIELD_OFFSET (field),
    3851    119990988 :                         DECL_FIELD_BIT_OFFSET (field));
    3852              : }
    3853              : 
    3854              : /* Likewise, but return as an integer.  It must be representable in
    3855              :    that way (since it could be a signed value, we don't have the
    3856              :    option of returning -1 like int_size_in_byte can.  */
    3857              : 
    3858              : HOST_WIDE_INT
    3859     10119169 : int_byte_position (const_tree field)
    3860              : {
    3861     10119169 :   return tree_to_shwi (byte_position (field));
    3862              : }
    3863              : 
    3864              : /* Return, as a tree node, the number of elements for TYPE (which is an
    3865              :    ARRAY_TYPE) minus one.  This counts only elements of the top array.  */
    3866              : 
    3867              : tree
    3868    114639927 : array_type_nelts_minus_one (const_tree type)
    3869              : {
    3870    114639927 :   tree index_type, min, max;
    3871              : 
    3872              :   /* If they did it with unspecified bounds, then we should have already
    3873              :      given an error about it before we got here.  */
    3874    114639927 :   if (! TYPE_DOMAIN (type))
    3875     10176127 :     return error_mark_node;
    3876              : 
    3877    104463800 :   index_type = TYPE_DOMAIN (type);
    3878    104463800 :   min = TYPE_MIN_VALUE (index_type);
    3879    104463800 :   max = TYPE_MAX_VALUE (index_type);
    3880              : 
    3881              :   /* TYPE_MAX_VALUE may not be set if the array has unknown length.  */
    3882    104463800 :   if (!max)
    3883              :     {
    3884              :       /* zero sized arrays are represented from C FE as complete types with
    3885              :          NULL TYPE_MAX_VALUE and zero TYPE_SIZE, while C++ FE represents
    3886              :          them as min 0, max -1.  */
    3887      1293703 :       if (COMPLETE_TYPE_P (type)
    3888         3151 :           && integer_zerop (TYPE_SIZE (type))
    3889      1296854 :           && integer_zerop (min))
    3890         3151 :         return build_int_cst (TREE_TYPE (min), -1);
    3891              : 
    3892      1290552 :       return error_mark_node;
    3893              :     }
    3894              : 
    3895    103170097 :   return (integer_zerop (min)
    3896    103170097 :           ? max
    3897      1175284 :           : fold_build2 (MINUS_EXPR, TREE_TYPE (max), max, min));
    3898              : }
    3899              : 
    3900              : /* Return, as an INTEGER_CST node, the number of elements for TYPE
    3901              :    (which is an ARRAY_TYPE).  This counts only elements of the top
    3902              :    array.  */
    3903              : 
    3904              : tree
    3905     25141283 : array_type_nelts_top (tree type)
    3906              : {
    3907     25141283 :   return fold_build2_loc (input_location,
    3908              :                       PLUS_EXPR, sizetype,
    3909              :                       array_type_nelts_minus_one (type),
    3910     25141283 :                       size_one_node);
    3911              : }
    3912              : 
    3913              : /* If arg is static -- a reference to an object in static storage -- then
    3914              :    return the object.  This is not the same as the C meaning of `static'.
    3915              :    If arg isn't static, return NULL.  */
    3916              : 
    3917              : tree
    3918   1232602016 : staticp (tree arg)
    3919              : {
    3920   1233681406 :   switch (TREE_CODE (arg))
    3921              :     {
    3922              :     case FUNCTION_DECL:
    3923              :       /* Nested functions are static, even though taking their address will
    3924              :          involve a trampoline as we unnest the nested function and create
    3925              :          the trampoline on the tree level.  */
    3926              :       return arg;
    3927              : 
    3928    744291653 :     case VAR_DECL:
    3929    587948808 :       return ((TREE_STATIC (arg) || DECL_EXTERNAL (arg))
    3930    202366882 :               && ! DECL_THREAD_LOCAL_P (arg)
    3931    200493172 :               && ! DECL_DLLIMPORT_P (arg)
    3932    744291653 :               ? arg : NULL);
    3933              : 
    3934       700175 :     case CONST_DECL:
    3935           44 :       return ((TREE_STATIC (arg) || DECL_EXTERNAL (arg))
    3936       700175 :               ? arg : NULL);
    3937              : 
    3938            0 :     case CONSTRUCTOR:
    3939            0 :       return TREE_STATIC (arg) ? arg : NULL;
    3940              : 
    3941              :     case LABEL_DECL:
    3942              :     case STRING_CST:
    3943              :       return arg;
    3944              : 
    3945       825117 :     case COMPONENT_REF:
    3946              :       /* If the thing being referenced is not a field, then it is
    3947              :          something language specific.  */
    3948       825117 :       gcc_assert (TREE_CODE (TREE_OPERAND (arg, 1)) == FIELD_DECL);
    3949              : 
    3950              :       /* If we are referencing a bitfield, we can't evaluate an
    3951              :          ADDR_EXPR at compile time and so it isn't a constant.  */
    3952       825117 :       if (DECL_BIT_FIELD (TREE_OPERAND (arg, 1)))
    3953              :         return NULL;
    3954              : 
    3955       825117 :       return staticp (TREE_OPERAND (arg, 0));
    3956              : 
    3957              :     case BIT_FIELD_REF:
    3958              :       return NULL;
    3959              : 
    3960        35109 :     case INDIRECT_REF:
    3961        35109 :       return TREE_CONSTANT (TREE_OPERAND (arg, 0)) ? arg : NULL;
    3962              : 
    3963       254161 :     case ARRAY_REF:
    3964       254161 :     case ARRAY_RANGE_REF:
    3965       254161 :       if (TREE_CODE (TYPE_SIZE (TREE_TYPE (arg))) == INTEGER_CST
    3966       254161 :           && TREE_CODE (TREE_OPERAND (arg, 1)) == INTEGER_CST)
    3967       253817 :         return staticp (TREE_OPERAND (arg, 0));
    3968              :       else
    3969              :         return NULL;
    3970              : 
    3971          456 :     case REALPART_EXPR:
    3972          456 :     case IMAGPART_EXPR:
    3973          456 :       return staticp (TREE_OPERAND (arg, 0));
    3974              : 
    3975          934 :     case COMPOUND_LITERAL_EXPR:
    3976          934 :       return TREE_STATIC (COMPOUND_LITERAL_EXPR_DECL (arg)) ? arg : NULL;
    3977              : 
    3978              :     default:
    3979              :       return NULL;
    3980              :     }
    3981              : }
    3982              : 
    3983              : 
    3984              : 
    3985              : 
    3986              : /* Return whether OP is a DECL whose address is function-invariant.  */
    3987              : 
    3988              : bool
    3989   5371257957 : decl_address_invariant_p (const_tree op)
    3990              : {
    3991              :   /* The conditions below are slightly less strict than the one in
    3992              :      staticp.  */
    3993              : 
    3994   5371257957 :   switch (TREE_CODE (op))
    3995              :     {
    3996              :     case PARM_DECL:
    3997              :     case RESULT_DECL:
    3998              :     case LABEL_DECL:
    3999              :     case FUNCTION_DECL:
    4000              :       return true;
    4001              : 
    4002   2958007122 :     case VAR_DECL:
    4003   2249261389 :       if ((TREE_STATIC (op) || DECL_EXTERNAL (op))
    4004   2107280549 :           || DECL_THREAD_LOCAL_P (op)
    4005   2107280549 :           || DECL_CONTEXT (op) == current_function_decl
    4006   2965953236 :           || decl_function_context (op) == current_function_decl)
    4007              :         return true;
    4008              :       break;
    4009              : 
    4010     26127987 :     case CONST_DECL:
    4011            0 :       if ((TREE_STATIC (op) || DECL_EXTERNAL (op))
    4012     26127987 :           || decl_function_context (op) == current_function_decl)
    4013              :         return true;
    4014              :       break;
    4015              : 
    4016              :     default:
    4017              :       break;
    4018              :     }
    4019              : 
    4020              :   return false;
    4021              : }
    4022              : 
    4023              : /* Return whether OP is a DECL whose address is interprocedural-invariant.  */
    4024              : 
    4025              : bool
    4026      3377199 : decl_address_ip_invariant_p (const_tree op)
    4027              : {
    4028              :   /* The conditions below are slightly less strict than the one in
    4029              :      staticp.  */
    4030              : 
    4031      3377199 :   symtab_node* node;
    4032      3377199 :   switch (TREE_CODE (op))
    4033              :     {
    4034              :     case LABEL_DECL:
    4035              :     case STRING_CST:
    4036              :       return true;
    4037              : 
    4038       137136 :     case FUNCTION_DECL:
    4039              :       /* Disable const propagation of symbols defined in assembly.  */
    4040       137136 :       node = symtab_node::get (op);
    4041       137136 :       return !node || !node->must_remain_in_tu_name;
    4042              : 
    4043      3041523 :     case VAR_DECL:
    4044      3041523 :       if (TREE_STATIC (op) || DECL_EXTERNAL (op))
    4045              :           {
    4046              :             /* Disable const propagation of symbols defined in assembly.  */
    4047       853170 :             node = symtab_node::get (op);
    4048       853170 :             if (node && node->must_remain_in_tu_name)
    4049              :               return false;
    4050              :           }
    4051      2265287 :       if (((TREE_STATIC (op) || DECL_EXTERNAL (op))
    4052       853167 :            && !DECL_DLLIMPORT_P (op))
    4053      5229873 :           || DECL_THREAD_LOCAL_P (op))
    4054              :         return true;
    4055              :       break;
    4056              : 
    4057       108496 :     case CONST_DECL:
    4058       108496 :       if ((TREE_STATIC (op) || DECL_EXTERNAL (op)))
    4059              :         return true;
    4060              :       break;
    4061              : 
    4062              :     default:
    4063              :       break;
    4064              :     }
    4065              : 
    4066              :   return false;
    4067              : }
    4068              : 
    4069              : /* Return true if T is an object with invariant address.  */
    4070              : 
    4071              : bool
    4072        45845 : address_invariant_p (tree t)
    4073              : {
    4074        53838 :   while (handled_component_p (t))
    4075              :     {
    4076         8992 :       switch (TREE_CODE (t))
    4077              :         {
    4078         1481 :         case ARRAY_REF:
    4079         1481 :         case ARRAY_RANGE_REF:
    4080         1481 :           if (!tree_invariant_p (TREE_OPERAND (t, 1))
    4081          482 :               || TREE_OPERAND (t, 2) != NULL_TREE
    4082         1963 :               || TREE_OPERAND (t, 3) != NULL_TREE)
    4083              :             return false;
    4084              :           break;
    4085              : 
    4086         7352 :         case COMPONENT_REF:
    4087         7352 :           if (TREE_OPERAND (t, 2) != NULL_TREE)
    4088              :             return false;
    4089              :           break;
    4090              : 
    4091              :         default:
    4092              :           break;
    4093              :         }
    4094         7993 :       t = TREE_OPERAND (t, 0);
    4095              :     }
    4096              : 
    4097        44846 :   STRIP_ANY_LOCATION_WRAPPER (t);
    4098        44846 :   return CONSTANT_CLASS_P (t) || decl_address_invariant_p (t);
    4099              : }
    4100              : 
    4101              : 
    4102              : /* Return true if T is function-invariant (internal function, does
    4103              :    not handle arithmetic; that's handled in skip_simple_arithmetic and
    4104              :    tree_invariant_p).  */
    4105              : 
    4106              : static bool
    4107     16136100 : tree_invariant_p_1 (tree t)
    4108              : {
    4109     16136100 :   if (TREE_CONSTANT (t) || (TREE_READONLY (t) && !TREE_SIDE_EFFECTS (t)))
    4110              :     return true;
    4111              : 
    4112     13493303 :   switch (TREE_CODE (t))
    4113              :     {
    4114              :     case SAVE_EXPR:
    4115              :     case TARGET_EXPR:
    4116              :       return true;
    4117              : 
    4118        45793 :     case ADDR_EXPR:
    4119        45793 :       return address_invariant_p (TREE_OPERAND (t, 0));
    4120              : 
    4121              :     default:
    4122              :       break;
    4123              :     }
    4124              : 
    4125              :   return false;
    4126              : }
    4127              : 
    4128              : /* Return true if T is function-invariant.  */
    4129              : 
    4130              : bool
    4131     12641424 : tree_invariant_p (tree t)
    4132              : {
    4133     12641424 :   tree inner = skip_simple_arithmetic (t);
    4134     12641424 :   return tree_invariant_p_1 (inner);
    4135              : }
    4136              : 
    4137              : /* Wrap a SAVE_EXPR around EXPR, if appropriate.
    4138              :    Do this to any expression which may be used in more than one place,
    4139              :    but must be evaluated only once.
    4140              : 
    4141              :    Normally, expand_expr would reevaluate the expression each time.
    4142              :    Calling save_expr produces something that is evaluated and recorded
    4143              :    the first time expand_expr is called on it.  Subsequent calls to
    4144              :    expand_expr just reuse the recorded value.
    4145              : 
    4146              :    The call to expand_expr that generates code that actually computes
    4147              :    the value is the first call *at compile time*.  Subsequent calls
    4148              :    *at compile time* generate code to use the saved value.
    4149              :    This produces correct result provided that *at run time* control
    4150              :    always flows through the insns made by the first expand_expr
    4151              :    before reaching the other places where the save_expr was evaluated.
    4152              :    You, the caller of save_expr, must make sure this is so.
    4153              : 
    4154              :    Constants, and certain read-only nodes, are returned with no
    4155              :    SAVE_EXPR because that is safe.  Expressions containing placeholders
    4156              :    are not touched; see tree.def for an explanation of what these
    4157              :    are used for.  */
    4158              : 
    4159              : tree
    4160      3494687 : save_expr (tree expr)
    4161              : {
    4162      3494687 :   tree inner;
    4163              : 
    4164              :   /* If the tree evaluates to a constant, then we don't want to hide that
    4165              :      fact (i.e. this allows further folding, and direct checks for constants).
    4166              :      However, a read-only object that has side effects cannot be bypassed.
    4167              :      Since it is no problem to reevaluate literals, we just return the
    4168              :      literal node.  */
    4169      3494687 :   inner = skip_simple_arithmetic (expr);
    4170      3494687 :   if (TREE_CODE (inner) == ERROR_MARK)
    4171              :     return inner;
    4172              : 
    4173      3494676 :   if (tree_invariant_p_1 (inner))
    4174              :     return expr;
    4175              : 
    4176              :   /* If INNER contains a PLACEHOLDER_EXPR, we must evaluate it each time, since
    4177              :      it means that the size or offset of some field of an object depends on
    4178              :      the value within another field.
    4179              : 
    4180              :      Note that it must not be the case that EXPR contains both a PLACEHOLDER_EXPR
    4181              :      and some variable since it would then need to be both evaluated once and
    4182              :      evaluated more than once.  Front-ends must assure this case cannot
    4183              :      happen by surrounding any such subexpressions in their own SAVE_EXPR
    4184              :      and forcing evaluation at the proper time.  */
    4185      2439975 :   if (contains_placeholder_p (inner))
    4186              :     return expr;
    4187              : 
    4188      2439975 :   expr = build1_loc (EXPR_LOCATION (expr), SAVE_EXPR, TREE_TYPE (expr), expr);
    4189              : 
    4190              :   /* This expression might be placed ahead of a jump to ensure that the
    4191              :      value was computed on both sides of the jump.  So make sure it isn't
    4192              :      eliminated as dead.  */
    4193      2439975 :   TREE_SIDE_EFFECTS (expr) = 1;
    4194      2439975 :   return expr;
    4195              : }
    4196              : 
    4197              : /* Look inside EXPR into any simple arithmetic operations.  Return the
    4198              :    outermost non-arithmetic or non-invariant node.  */
    4199              : 
    4200              : tree
    4201     16136111 : skip_simple_arithmetic (tree expr)
    4202              : {
    4203              :   /* We don't care about whether this can be used as an lvalue in this
    4204              :      context.  */
    4205     16151884 :   while (TREE_CODE (expr) == NON_LVALUE_EXPR)
    4206        15773 :     expr = TREE_OPERAND (expr, 0);
    4207              : 
    4208              :   /* If we have simple operations applied to a SAVE_EXPR or to a SAVE_EXPR and
    4209              :      a constant, it will be more efficient to not make another SAVE_EXPR since
    4210              :      it will allow better simplification and GCSE will be able to merge the
    4211              :      computations if they actually occur.  */
    4212     40638522 :   while (true)
    4213              :     {
    4214     40638522 :       if (UNARY_CLASS_P (expr))
    4215     15324053 :         expr = TREE_OPERAND (expr, 0);
    4216     25314469 :       else if (BINARY_CLASS_P (expr))
    4217              :         {
    4218              :           /* Before commutative binary operands are canonicalized,
    4219              :              it is quite common to have constants in the first operand.
    4220              :              Check for that common case first so that we don't walk
    4221              :              large expressions with tree_invariant_p unnecessarily.
    4222              :              This can still have terrible compile time complexity,
    4223              :              we should limit the depth of the tree_invariant_p and
    4224              :              skip_simple_arithmetic recursion.  */
    4225      9232947 :           if ((TREE_CONSTANT (TREE_OPERAND (expr, 0))
    4226      9222711 :                || (TREE_READONLY (TREE_OPERAND (expr, 0))
    4227        10558 :                    && !TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 0))))
    4228      9243469 :               && tree_invariant_p (TREE_OPERAND (expr, 0)))
    4229        20758 :             expr = TREE_OPERAND (expr, 1);
    4230      9212189 :           else if (tree_invariant_p (TREE_OPERAND (expr, 1)))
    4231      9147718 :             expr = TREE_OPERAND (expr, 0);
    4232        64471 :           else if (tree_invariant_p (TREE_OPERAND (expr, 0)))
    4233         9882 :             expr = TREE_OPERAND (expr, 1);
    4234              :           else
    4235              :             break;
    4236              :         }
    4237              :       else
    4238              :         break;
    4239              :     }
    4240              : 
    4241     16136111 :   return expr;
    4242              : }
    4243              : 
    4244              : /* Look inside EXPR into simple arithmetic operations involving constants.
    4245              :    Return the outermost non-arithmetic or non-constant node.  */
    4246              : 
    4247              : tree
    4248            0 : skip_simple_constant_arithmetic (tree expr)
    4249              : {
    4250            0 :   while (TREE_CODE (expr) == NON_LVALUE_EXPR)
    4251            0 :     expr = TREE_OPERAND (expr, 0);
    4252              : 
    4253            0 :   while (true)
    4254              :     {
    4255            0 :       if (UNARY_CLASS_P (expr))
    4256            0 :         expr = TREE_OPERAND (expr, 0);
    4257            0 :       else if (BINARY_CLASS_P (expr))
    4258              :         {
    4259            0 :           if (TREE_CONSTANT (TREE_OPERAND (expr, 1)))
    4260            0 :             expr = TREE_OPERAND (expr, 0);
    4261            0 :           else if (TREE_CONSTANT (TREE_OPERAND (expr, 0)))
    4262            0 :             expr = TREE_OPERAND (expr, 1);
    4263              :           else
    4264              :             break;
    4265              :         }
    4266              :       else
    4267              :         break;
    4268              :     }
    4269              : 
    4270            0 :   return expr;
    4271              : }
    4272              : 
    4273              : /* Return which tree structure is used by T.  */
    4274              : 
    4275              : enum tree_node_structure_enum
    4276  44618388287 : tree_node_structure (const_tree t)
    4277              : {
    4278  44618388287 :   const enum tree_code code = TREE_CODE (t);
    4279  44618388287 :   return tree_node_structure_for_code (code);
    4280              : }
    4281              : 
    4282              : /* Set various status flags when building a CALL_EXPR object T.  */
    4283              : 
    4284              : static void
    4285    293920267 : process_call_operands (tree t)
    4286              : {
    4287    293920267 :   bool side_effects = TREE_SIDE_EFFECTS (t);
    4288    293920267 :   bool read_only = false;
    4289    293920267 :   int i = call_expr_flags (t);
    4290              : 
    4291              :   /* Calls have side-effects, except those to const or pure functions.  */
    4292    293920267 :   if ((i & ECF_LOOPING_CONST_OR_PURE) || !(i & (ECF_CONST | ECF_PURE)))
    4293              :     side_effects = true;
    4294              :   /* Propagate TREE_READONLY of arguments for const functions.  */
    4295     61339515 :   if (i & ECF_CONST)
    4296     59722274 :     read_only = true;
    4297              : 
    4298    293920267 :   if (!side_effects || read_only)
    4299    307411428 :     for (i = 1; i < TREE_OPERAND_LENGTH (t); i++)
    4300              :       {
    4301    246084243 :         tree op = TREE_OPERAND (t, i);
    4302    246084243 :         if (op && TREE_SIDE_EFFECTS (op))
    4303              :           side_effects = true;
    4304    246084243 :         if (op && !TREE_READONLY (op) && !CONSTANT_CLASS_P (op))
    4305              :           read_only = false;
    4306              :       }
    4307              : 
    4308    293920267 :   TREE_SIDE_EFFECTS (t) = side_effects;
    4309    293920267 :   TREE_READONLY (t) = read_only;
    4310    293920267 : }
    4311              : 
    4312              : /* Return true if EXP contains a PLACEHOLDER_EXPR, i.e. if it represents a
    4313              :    size or offset that depends on a field within a record.  */
    4314              : 
    4315              : bool
    4316     38987151 : contains_placeholder_p (const_tree exp)
    4317              : {
    4318     38987151 :   enum tree_code code;
    4319              : 
    4320     38987151 :   if (!exp)
    4321              :     return false;
    4322              : 
    4323     38987151 :   code = TREE_CODE (exp);
    4324     38987151 :   if (code == PLACEHOLDER_EXPR)
    4325              :     return true;
    4326              : 
    4327     38987151 :   switch (TREE_CODE_CLASS (code))
    4328              :     {
    4329      1186552 :     case tcc_reference:
    4330              :       /* Don't look at any PLACEHOLDER_EXPRs that might be in index or bit
    4331              :          position computations since they will be converted into a
    4332              :          WITH_RECORD_EXPR involving the reference, which will assume
    4333              :          here will be valid.  */
    4334      1186552 :       return CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0));
    4335              : 
    4336       580017 :     case tcc_exceptional:
    4337       580017 :       if (code == TREE_LIST)
    4338            0 :         return (CONTAINS_PLACEHOLDER_P (TREE_VALUE (exp))
    4339            0 :                 || CONTAINS_PLACEHOLDER_P (TREE_CHAIN (exp)));
    4340              :       break;
    4341              : 
    4342     33827547 :     case tcc_unary:
    4343     33827547 :     case tcc_binary:
    4344     33827547 :     case tcc_comparison:
    4345     33827547 :     case tcc_expression:
    4346     33827547 :       switch (code)
    4347              :         {
    4348         7337 :         case COMPOUND_EXPR:
    4349              :           /* Ignoring the first operand isn't quite right, but works best.  */
    4350         7337 :           return CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 1));
    4351              : 
    4352         4660 :         case COND_EXPR:
    4353         9320 :           return (CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0))
    4354         4660 :                   || CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 1))
    4355         9320 :                   || CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 2)));
    4356              : 
    4357              :         case SAVE_EXPR:
    4358              :           /* The save_expr function never wraps anything containing
    4359              :              a PLACEHOLDER_EXPR. */
    4360              :           return false;
    4361              : 
    4362     24637654 :         default:
    4363     24637654 :           break;
    4364              :         }
    4365              : 
    4366     24637654 :       switch (TREE_CODE_LENGTH (code))
    4367              :         {
    4368     15019795 :         case 1:
    4369     15019795 :           return CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0));
    4370      9520651 :         case 2:
    4371     19039760 :           return (CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0))
    4372     19039760 :                   || CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 1)));
    4373              :         default:
    4374              :           return false;
    4375              :         }
    4376              : 
    4377       807510 :     case tcc_vl_exp:
    4378       807510 :       switch (code)
    4379              :         {
    4380       807510 :         case CALL_EXPR:
    4381       807510 :           {
    4382       807510 :             const_tree arg;
    4383       807510 :             const_call_expr_arg_iterator iter;
    4384      2808539 :             FOR_EACH_CONST_CALL_EXPR_ARG (arg, iter, exp)
    4385      1193519 :               if (CONTAINS_PLACEHOLDER_P (arg))
    4386              :                 return true;
    4387              :             return false;
    4388              :           }
    4389              :         default:
    4390              :           return false;
    4391              :         }
    4392              : 
    4393              :     default:
    4394              :       return false;
    4395              :     }
    4396              :   return false;
    4397              : }
    4398              : 
    4399              : /* Return true if any part of the structure of TYPE involves a PLACEHOLDER_EXPR
    4400              :    directly.  This includes size, bounds, qualifiers (for QUAL_UNION_TYPE) and
    4401              :    field positions.  */
    4402              : 
    4403              : static bool
    4404       759590 : type_contains_placeholder_1 (const_tree type)
    4405              : {
    4406              :   /* If the size contains a placeholder or the parent type (component type in
    4407              :      the case of arrays) type involves a placeholder, this type does.  */
    4408      1512554 :   if (CONTAINS_PLACEHOLDER_P (TYPE_SIZE (type))
    4409       759590 :       || CONTAINS_PLACEHOLDER_P (TYPE_SIZE_UNIT (type))
    4410      1519180 :       || (!POINTER_TYPE_P (type)
    4411       623267 :           && TREE_TYPE (type)
    4412        83405 :           && type_contains_placeholder_p (TREE_TYPE (type))))
    4413              :     return true;
    4414              : 
    4415              :   /* Now do type-specific checks.  Note that the last part of the check above
    4416              :      greatly limits what we have to do below.  */
    4417       759590 :   switch (TREE_CODE (type))
    4418              :     {
    4419              :     case VOID_TYPE:
    4420              :     case OPAQUE_TYPE:
    4421              :     case COMPLEX_TYPE:
    4422              :     case ENUMERAL_TYPE:
    4423              :     case BOOLEAN_TYPE:
    4424              :     case POINTER_TYPE:
    4425              :     case OFFSET_TYPE:
    4426              :     case REFERENCE_TYPE:
    4427              :     case METHOD_TYPE:
    4428              :     case FUNCTION_TYPE:
    4429              :     case VECTOR_TYPE:
    4430              :     case NULLPTR_TYPE:
    4431              :       return false;
    4432              : 
    4433       162750 :     case INTEGER_TYPE:
    4434       162750 :     case BITINT_TYPE:
    4435       162750 :     case REAL_TYPE:
    4436       162750 :     case FIXED_POINT_TYPE:
    4437              :       /* Here we just check the bounds.  */
    4438       317633 :       return (CONTAINS_PLACEHOLDER_P (TYPE_MIN_VALUE (type))
    4439       317633 :               || CONTAINS_PLACEHOLDER_P (TYPE_MAX_VALUE (type)));
    4440              : 
    4441        37512 :     case ARRAY_TYPE:
    4442              :       /* We have already checked the component type above, so just check
    4443              :          the domain type.  Flexible array members have a null domain.  */
    4444        75012 :       return TYPE_DOMAIN (type) ?
    4445        37500 :         type_contains_placeholder_p (TYPE_DOMAIN (type)) : false;
    4446              : 
    4447       404000 :     case RECORD_TYPE:
    4448       404000 :     case UNION_TYPE:
    4449       404000 :     case QUAL_UNION_TYPE:
    4450       404000 :       {
    4451       404000 :         tree field;
    4452              : 
    4453     11727212 :         for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    4454     11323212 :           if (TREE_CODE (field) == FIELD_DECL
    4455     11323212 :               && (CONTAINS_PLACEHOLDER_P (DECL_FIELD_OFFSET (field))
    4456       940950 :                   || (TREE_CODE (type) == QUAL_UNION_TYPE
    4457            0 :                       && CONTAINS_PLACEHOLDER_P (DECL_QUALIFIER (field)))
    4458       940950 :                   || type_contains_placeholder_p (TREE_TYPE (field))))
    4459              :             return true;
    4460              : 
    4461              :         return false;
    4462              :       }
    4463              : 
    4464            0 :     default:
    4465            0 :       gcc_unreachable ();
    4466              :     }
    4467              : }
    4468              : 
    4469              : /* Wrapper around above function used to cache its result.  */
    4470              : 
    4471              : bool
    4472      2704932 : type_contains_placeholder_p (tree type)
    4473              : {
    4474      2704932 :   bool result;
    4475              : 
    4476              :   /* If the contains_placeholder_bits field has been initialized,
    4477              :      then we know the answer.  */
    4478      2704932 :   if (TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type) > 0)
    4479      1945342 :     return TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type) - 1;
    4480              : 
    4481              :   /* Indicate that we've seen this type node, and the answer is false.
    4482              :      This is what we want to return if we run into recursion via fields.  */
    4483       759590 :   TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type) = 1;
    4484              : 
    4485              :   /* Compute the real value.  */
    4486       759590 :   result = type_contains_placeholder_1 (type);
    4487              : 
    4488              :   /* Store the real value.  */
    4489       759590 :   TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type) = result + 1;
    4490              : 
    4491       759590 :   return result;
    4492              : }
    4493              : 
    4494              : /* Push tree EXP onto vector QUEUE if it is not already present.  */
    4495              : 
    4496              : static void
    4497            0 : push_without_duplicates (tree exp, vec<tree> *queue)
    4498              : {
    4499            0 :   unsigned int i;
    4500            0 :   tree iter;
    4501              : 
    4502            0 :   FOR_EACH_VEC_ELT (*queue, i, iter)
    4503            0 :     if (simple_cst_equal (iter, exp) == 1)
    4504              :       break;
    4505              : 
    4506            0 :   if (!iter)
    4507            0 :     queue->safe_push (exp);
    4508            0 : }
    4509              : 
    4510              : /* Given a tree EXP, find all occurrences of references to fields
    4511              :    in a PLACEHOLDER_EXPR and place them in vector REFS without
    4512              :    duplicates.  Also record VAR_DECLs and CONST_DECLs.  Note that
    4513              :    we assume here that EXP contains only arithmetic expressions
    4514              :    or CALL_EXPRs with PLACEHOLDER_EXPRs occurring only in their
    4515              :    argument list.  */
    4516              : 
    4517              : void
    4518            0 : find_placeholder_in_expr (tree exp, vec<tree> *refs)
    4519              : {
    4520            0 :   enum tree_code code = TREE_CODE (exp);
    4521            0 :   tree inner;
    4522            0 :   int i;
    4523              : 
    4524              :   /* We handle TREE_LIST and COMPONENT_REF separately.  */
    4525            0 :   if (code == TREE_LIST)
    4526              :     {
    4527            0 :       FIND_PLACEHOLDER_IN_EXPR (TREE_CHAIN (exp), refs);
    4528            0 :       FIND_PLACEHOLDER_IN_EXPR (TREE_VALUE (exp), refs);
    4529              :     }
    4530            0 :   else if (code == COMPONENT_REF)
    4531              :     {
    4532            0 :       for (inner = TREE_OPERAND (exp, 0);
    4533            0 :            REFERENCE_CLASS_P (inner);
    4534            0 :            inner = TREE_OPERAND (inner, 0))
    4535              :         ;
    4536              : 
    4537            0 :       if (TREE_CODE (inner) == PLACEHOLDER_EXPR)
    4538            0 :         push_without_duplicates (exp, refs);
    4539              :       else
    4540            0 :         FIND_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), refs);
    4541              :    }
    4542              :   else
    4543            0 :     switch (TREE_CODE_CLASS (code))
    4544              :       {
    4545              :       case tcc_constant:
    4546              :         break;
    4547              : 
    4548            0 :       case tcc_declaration:
    4549              :         /* Variables allocated to static storage can stay.  */
    4550            0 :         if (!TREE_STATIC (exp))
    4551            0 :           push_without_duplicates (exp, refs);
    4552              :         break;
    4553              : 
    4554            0 :       case tcc_expression:
    4555              :         /* This is the pattern built in ada/make_aligning_type.  */
    4556            0 :         if (code == ADDR_EXPR
    4557            0 :             && TREE_CODE (TREE_OPERAND (exp, 0)) == PLACEHOLDER_EXPR)
    4558              :           {
    4559            0 :             push_without_duplicates (exp, refs);
    4560            0 :             break;
    4561              :           }
    4562              : 
    4563              :         /* Fall through.  */
    4564              : 
    4565              :       case tcc_exceptional:
    4566              :       case tcc_unary:
    4567              :       case tcc_binary:
    4568              :       case tcc_comparison:
    4569              :       case tcc_reference:
    4570            0 :         for (i = 0; i < TREE_CODE_LENGTH (code); i++)
    4571            0 :           FIND_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, i), refs);
    4572              :         break;
    4573              : 
    4574              :       case tcc_vl_exp:
    4575            0 :         for (i = 1; i < TREE_OPERAND_LENGTH (exp); i++)
    4576            0 :           FIND_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, i), refs);
    4577              :         break;
    4578              : 
    4579            0 :       default:
    4580            0 :         gcc_unreachable ();
    4581              :       }
    4582            0 : }
    4583              : 
    4584              : /* Given a tree EXP, a FIELD_DECL F, and a replacement value R,
    4585              :    return a tree with all occurrences of references to F in a
    4586              :    PLACEHOLDER_EXPR replaced by R.  Also handle VAR_DECLs and
    4587              :    CONST_DECLs.  Note that we assume here that EXP contains only
    4588              :    arithmetic expressions or CALL_EXPRs with PLACEHOLDER_EXPRs
    4589              :    occurring only in their argument list.  */
    4590              : 
    4591              : tree
    4592            0 : substitute_in_expr (tree exp, tree f, tree r)
    4593              : {
    4594            0 :   enum tree_code code = TREE_CODE (exp);
    4595            0 :   tree op0, op1, op2, op3;
    4596            0 :   tree new_tree;
    4597              : 
    4598              :   /* We handle TREE_LIST and COMPONENT_REF separately.  */
    4599            0 :   if (code == TREE_LIST)
    4600              :     {
    4601            0 :       op0 = SUBSTITUTE_IN_EXPR (TREE_CHAIN (exp), f, r);
    4602            0 :       op1 = SUBSTITUTE_IN_EXPR (TREE_VALUE (exp), f, r);
    4603            0 :       if (op0 == TREE_CHAIN (exp) && op1 == TREE_VALUE (exp))
    4604              :         return exp;
    4605              : 
    4606            0 :       return tree_cons (TREE_PURPOSE (exp), op1, op0);
    4607              :     }
    4608            0 :   else if (code == COMPONENT_REF)
    4609              :     {
    4610            0 :       tree inner;
    4611              : 
    4612              :       /* If this expression is getting a value from a PLACEHOLDER_EXPR
    4613              :          and it is the right field, replace it with R.  */
    4614            0 :       for (inner = TREE_OPERAND (exp, 0);
    4615            0 :            REFERENCE_CLASS_P (inner);
    4616            0 :            inner = TREE_OPERAND (inner, 0))
    4617              :         ;
    4618              : 
    4619              :       /* The field.  */
    4620            0 :       op1 = TREE_OPERAND (exp, 1);
    4621              : 
    4622            0 :       if (TREE_CODE (inner) == PLACEHOLDER_EXPR && op1 == f)
    4623              :         return r;
    4624              : 
    4625              :       /* If this expression hasn't been completed let, leave it alone.  */
    4626            0 :       if (TREE_CODE (inner) == PLACEHOLDER_EXPR && !TREE_TYPE (inner))
    4627              :         return exp;
    4628              : 
    4629            0 :       op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
    4630            0 :       if (op0 == TREE_OPERAND (exp, 0))
    4631              :         return exp;
    4632              : 
    4633            0 :       new_tree
    4634            0 :         = fold_build3 (COMPONENT_REF, TREE_TYPE (exp), op0, op1, NULL_TREE);
    4635              :    }
    4636              :   else
    4637            0 :     switch (TREE_CODE_CLASS (code))
    4638              :       {
    4639              :       case tcc_constant:
    4640              :         return exp;
    4641              : 
    4642            0 :       case tcc_declaration:
    4643            0 :         if (exp == f)
    4644              :           return r;
    4645              :         else
    4646            0 :           return exp;
    4647              : 
    4648            0 :       case tcc_expression:
    4649            0 :         if (exp == f)
    4650              :           return r;
    4651              : 
    4652              :         /* Fall through.  */
    4653              : 
    4654            0 :       case tcc_exceptional:
    4655            0 :       case tcc_unary:
    4656            0 :       case tcc_binary:
    4657            0 :       case tcc_comparison:
    4658            0 :       case tcc_reference:
    4659            0 :         switch (TREE_CODE_LENGTH (code))
    4660              :           {
    4661              :           case 0:
    4662              :             return exp;
    4663              : 
    4664            0 :           case 1:
    4665            0 :             op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
    4666            0 :             if (op0 == TREE_OPERAND (exp, 0))
    4667              :               return exp;
    4668              : 
    4669            0 :             new_tree = fold_build1 (code, TREE_TYPE (exp), op0);
    4670            0 :             break;
    4671              : 
    4672            0 :           case 2:
    4673            0 :             op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
    4674            0 :             op1 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 1), f, r);
    4675              : 
    4676            0 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1))
    4677              :               return exp;
    4678              : 
    4679            0 :             new_tree = fold_build2 (code, TREE_TYPE (exp), op0, op1);
    4680            0 :             break;
    4681              : 
    4682            0 :           case 3:
    4683            0 :             op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
    4684            0 :             op1 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 1), f, r);
    4685            0 :             op2 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 2), f, r);
    4686              : 
    4687            0 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1)
    4688            0 :                 && op2 == TREE_OPERAND (exp, 2))
    4689              :               return exp;
    4690              : 
    4691            0 :             new_tree = fold_build3 (code, TREE_TYPE (exp), op0, op1, op2);
    4692            0 :             break;
    4693              : 
    4694            0 :           case 4:
    4695            0 :             op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
    4696            0 :             op1 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 1), f, r);
    4697            0 :             op2 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 2), f, r);
    4698            0 :             op3 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 3), f, r);
    4699              : 
    4700            0 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1)
    4701            0 :                 && op2 == TREE_OPERAND (exp, 2)
    4702            0 :                 && op3 == TREE_OPERAND (exp, 3))
    4703              :               return exp;
    4704              : 
    4705            0 :             new_tree
    4706            0 :               = fold (build4 (code, TREE_TYPE (exp), op0, op1, op2, op3));
    4707            0 :             break;
    4708              : 
    4709            0 :           default:
    4710            0 :             gcc_unreachable ();
    4711              :           }
    4712              :         break;
    4713              : 
    4714            0 :       case tcc_vl_exp:
    4715            0 :         {
    4716            0 :           int i;
    4717              : 
    4718            0 :           new_tree = NULL_TREE;
    4719              : 
    4720              :           /* If we are trying to replace F with a constant or with another
    4721              :              instance of one of the arguments of the call, inline back
    4722              :              functions which do nothing else than computing a value from
    4723              :              the arguments they are passed.  This makes it possible to
    4724              :              fold partially or entirely the replacement expression.  */
    4725            0 :           if (code == CALL_EXPR)
    4726              :             {
    4727            0 :               bool maybe_inline = false;
    4728            0 :               if (CONSTANT_CLASS_P (r))
    4729              :                 maybe_inline = true;
    4730              :               else
    4731            0 :                 for (i = 3; i < TREE_OPERAND_LENGTH (exp); i++)
    4732            0 :                   if (operand_equal_p (TREE_OPERAND (exp, i), r, 0))
    4733              :                     {
    4734              :                       maybe_inline = true;
    4735              :                       break;
    4736              :                     }
    4737            0 :               if (maybe_inline)
    4738              :                 {
    4739            0 :                   tree t = maybe_inline_call_in_expr (exp);
    4740            0 :                   if (t)
    4741            0 :                     return SUBSTITUTE_IN_EXPR (t, f, r);
    4742              :                 }
    4743              :             }
    4744              : 
    4745            0 :           for (i = 1; i < TREE_OPERAND_LENGTH (exp); i++)
    4746              :             {
    4747            0 :               tree op = TREE_OPERAND (exp, i);
    4748            0 :               tree new_op = SUBSTITUTE_IN_EXPR (op, f, r);
    4749            0 :               if (new_op != op)
    4750              :                 {
    4751            0 :                   if (!new_tree)
    4752            0 :                     new_tree = copy_node (exp);
    4753            0 :                   TREE_OPERAND (new_tree, i) = new_op;
    4754              :                 }
    4755              :             }
    4756              : 
    4757            0 :           if (new_tree)
    4758              :             {
    4759            0 :               new_tree = fold (new_tree);
    4760            0 :               if (TREE_CODE (new_tree) == CALL_EXPR)
    4761            0 :                 process_call_operands (new_tree);
    4762              :             }
    4763              :           else
    4764              :             return exp;
    4765              :         }
    4766              :         break;
    4767              : 
    4768            0 :       default:
    4769            0 :         gcc_unreachable ();
    4770              :       }
    4771              : 
    4772            0 :   TREE_READONLY (new_tree) |= TREE_READONLY (exp);
    4773              : 
    4774            0 :   if (code == INDIRECT_REF || code == ARRAY_REF || code == ARRAY_RANGE_REF)
    4775            0 :     TREE_THIS_NOTRAP (new_tree) |= TREE_THIS_NOTRAP (exp);
    4776              : 
    4777              :   return new_tree;
    4778              : }
    4779              : 
    4780              : /* Similar, but look for a PLACEHOLDER_EXPR in EXP and find a replacement
    4781              :    for it within OBJ, a tree that is an object or a chain of references.  */
    4782              : 
    4783              : tree
    4784       254411 : substitute_placeholder_in_expr (tree exp, tree obj)
    4785              : {
    4786       254411 :   enum tree_code code = TREE_CODE (exp);
    4787       254411 :   tree op0, op1, op2, op3;
    4788       254411 :   tree new_tree;
    4789              : 
    4790              :   /* If this is a PLACEHOLDER_EXPR, see if we find a corresponding type
    4791              :      in the chain of OBJ.  */
    4792       254411 :   if (code == PLACEHOLDER_EXPR)
    4793              :     {
    4794            0 :       tree need_type = TYPE_MAIN_VARIANT (TREE_TYPE (exp));
    4795            0 :       tree elt;
    4796              : 
    4797            0 :       for (elt = obj; elt != 0;
    4798            0 :            elt = ((TREE_CODE (elt) == COMPOUND_EXPR
    4799            0 :                    || TREE_CODE (elt) == COND_EXPR)
    4800            0 :                   ? TREE_OPERAND (elt, 1)
    4801            0 :                   : (REFERENCE_CLASS_P (elt)
    4802              :                      || UNARY_CLASS_P (elt)
    4803              :                      || BINARY_CLASS_P (elt)
    4804              :                      || VL_EXP_CLASS_P (elt)
    4805              :                      || EXPRESSION_CLASS_P (elt))
    4806            0 :                   ? TREE_OPERAND (elt, 0) : 0))
    4807            0 :         if (TYPE_MAIN_VARIANT (TREE_TYPE (elt)) == need_type)
    4808              :           return elt;
    4809              : 
    4810            0 :       for (elt = obj; elt != 0;
    4811            0 :            elt = ((TREE_CODE (elt) == COMPOUND_EXPR
    4812            0 :                    || TREE_CODE (elt) == COND_EXPR)
    4813            0 :                   ? TREE_OPERAND (elt, 1)
    4814            0 :                   : (REFERENCE_CLASS_P (elt)
    4815              :                      || UNARY_CLASS_P (elt)
    4816              :                      || BINARY_CLASS_P (elt)
    4817              :                      || VL_EXP_CLASS_P (elt)
    4818              :                      || EXPRESSION_CLASS_P (elt))
    4819            0 :                   ? TREE_OPERAND (elt, 0) : 0))
    4820            0 :         if (POINTER_TYPE_P (TREE_TYPE (elt))
    4821            0 :             && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (elt)))
    4822              :                 == need_type))
    4823            0 :           return fold_build1 (INDIRECT_REF, need_type, elt);
    4824              : 
    4825              :       /* If we didn't find it, return the original PLACEHOLDER_EXPR.  If it
    4826              :          survives until RTL generation, there will be an error.  */
    4827              :       return exp;
    4828              :     }
    4829              : 
    4830              :   /* TREE_LIST is special because we need to look at TREE_VALUE
    4831              :      and TREE_CHAIN, not TREE_OPERANDS.  */
    4832       254411 :   else if (code == TREE_LIST)
    4833              :     {
    4834            0 :       op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_CHAIN (exp), obj);
    4835            0 :       op1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_VALUE (exp), obj);
    4836            0 :       if (op0 == TREE_CHAIN (exp) && op1 == TREE_VALUE (exp))
    4837              :         return exp;
    4838              : 
    4839            0 :       return tree_cons (TREE_PURPOSE (exp), op1, op0);
    4840              :     }
    4841              :   else
    4842       254411 :     switch (TREE_CODE_CLASS (code))
    4843              :       {
    4844              :       case tcc_constant:
    4845              :       case tcc_declaration:
    4846              :         return exp;
    4847              : 
    4848        10195 :       case tcc_exceptional:
    4849        10195 :       case tcc_unary:
    4850        10195 :       case tcc_binary:
    4851        10195 :       case tcc_comparison:
    4852        10195 :       case tcc_expression:
    4853        10195 :       case tcc_reference:
    4854        10195 :       case tcc_statement:
    4855        10195 :         switch (TREE_CODE_LENGTH (code))
    4856              :           {
    4857              :           case 0:
    4858              :             return exp;
    4859              : 
    4860         7812 :           case 1:
    4861         7812 :             op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), obj);
    4862         7812 :             if (op0 == TREE_OPERAND (exp, 0))
    4863              :               return exp;
    4864              : 
    4865            0 :             new_tree = fold_build1 (code, TREE_TYPE (exp), op0);
    4866            0 :             break;
    4867              : 
    4868         2371 :           case 2:
    4869         2371 :             op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), obj);
    4870         2371 :             op1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 1), obj);
    4871              : 
    4872         2371 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1))
    4873              :               return exp;
    4874              : 
    4875            0 :             new_tree = fold_build2 (code, TREE_TYPE (exp), op0, op1);
    4876            0 :             break;
    4877              : 
    4878           12 :           case 3:
    4879           12 :             op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), obj);
    4880           12 :             op1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 1), obj);
    4881           12 :             op2 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 2), obj);
    4882              : 
    4883           24 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1)
    4884           24 :                 && op2 == TREE_OPERAND (exp, 2))
    4885              :               return exp;
    4886              : 
    4887            0 :             new_tree = fold_build3 (code, TREE_TYPE (exp), op0, op1, op2);
    4888            0 :             break;
    4889              : 
    4890            0 :           case 4:
    4891            0 :             op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), obj);
    4892            0 :             op1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 1), obj);
    4893            0 :             op2 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 2), obj);
    4894            0 :             op3 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 3), obj);
    4895              : 
    4896            0 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1)
    4897            0 :                 && op2 == TREE_OPERAND (exp, 2)
    4898            0 :                 && op3 == TREE_OPERAND (exp, 3))
    4899              :               return exp;
    4900              : 
    4901            0 :             new_tree
    4902            0 :               = fold (build4 (code, TREE_TYPE (exp), op0, op1, op2, op3));
    4903            0 :             break;
    4904              : 
    4905            0 :           default:
    4906            0 :             gcc_unreachable ();
    4907              :           }
    4908              :         break;
    4909              : 
    4910              :       case tcc_vl_exp:
    4911              :         {
    4912              :           int i;
    4913              : 
    4914              :           new_tree = NULL_TREE;
    4915              : 
    4916            0 :           for (i = 1; i < TREE_OPERAND_LENGTH (exp); i++)
    4917              :             {
    4918            0 :               tree op = TREE_OPERAND (exp, i);
    4919            0 :               tree new_op = SUBSTITUTE_PLACEHOLDER_IN_EXPR (op, obj);
    4920            0 :               if (new_op != op)
    4921              :                 {
    4922            0 :                   if (!new_tree)
    4923            0 :                     new_tree = copy_node (exp);
    4924            0 :                   TREE_OPERAND (new_tree, i) = new_op;
    4925              :                 }
    4926              :             }
    4927              : 
    4928            0 :           if (new_tree)
    4929              :             {
    4930            0 :               new_tree = fold (new_tree);
    4931            0 :               if (TREE_CODE (new_tree) == CALL_EXPR)
    4932            0 :                 process_call_operands (new_tree);
    4933              :             }
    4934              :           else
    4935              :             return exp;
    4936              :         }
    4937              :         break;
    4938              : 
    4939            0 :       default:
    4940            0 :         gcc_unreachable ();
    4941              :       }
    4942              : 
    4943            0 :   TREE_READONLY (new_tree) |= TREE_READONLY (exp);
    4944              : 
    4945            0 :   if (code == INDIRECT_REF || code == ARRAY_REF || code == ARRAY_RANGE_REF)
    4946            0 :     TREE_THIS_NOTRAP (new_tree) |= TREE_THIS_NOTRAP (exp);
    4947              : 
    4948              :   return new_tree;
    4949              : }
    4950              : 
    4951              : 
    4952              : /* Subroutine of stabilize_reference; this is called for subtrees of
    4953              :    references.  Any expression with side-effects must be put in a SAVE_EXPR
    4954              :    to ensure that it is only evaluated once.
    4955              : 
    4956              :    We don't put SAVE_EXPR nodes around everything, because assigning very
    4957              :    simple expressions to temporaries causes us to miss good opportunities
    4958              :    for optimizations.  Among other things, the opportunity to fold in the
    4959              :    addition of a constant into an addressing mode often gets lost, e.g.
    4960              :    "y[i+1] += x;".  In general, we take the approach that we should not make
    4961              :    an assignment unless we are forced into it - i.e., that any non-side effect
    4962              :    operator should be allowed, and that cse should take care of coalescing
    4963              :    multiple utterances of the same expression should that prove fruitful.  */
    4964              : 
    4965              : static tree
    4966       902572 : stabilize_reference_1 (tree e)
    4967              : {
    4968       902572 :   tree result;
    4969       902572 :   enum tree_code code = TREE_CODE (e);
    4970              : 
    4971              :   /* We cannot ignore const expressions because it might be a reference
    4972              :      to a const array but whose index contains side-effects.  But we can
    4973              :      ignore things that are actual constant or that already have been
    4974              :      handled by this function.  */
    4975              : 
    4976       902572 :   if (tree_invariant_p (e))
    4977              :     return e;
    4978              : 
    4979       134270 :   switch (TREE_CODE_CLASS (code))
    4980              :     {
    4981            0 :     case tcc_exceptional:
    4982              :       /* Always wrap STATEMENT_LIST into SAVE_EXPR, even if it doesn't
    4983              :          have side-effects.  */
    4984            0 :       if (code == STATEMENT_LIST)
    4985            0 :         return save_expr (e);
    4986              :       /* FALLTHRU */
    4987       104252 :     case tcc_type:
    4988       104252 :     case tcc_declaration:
    4989       104252 :     case tcc_comparison:
    4990       104252 :     case tcc_statement:
    4991       104252 :     case tcc_expression:
    4992       104252 :     case tcc_reference:
    4993       104252 :     case tcc_vl_exp:
    4994              :       /* If the expression has side-effects, then encase it in a SAVE_EXPR
    4995              :          so that it will only be evaluated once.  */
    4996              :       /* The reference (r) and comparison (<) classes could be handled as
    4997              :          below, but it is generally faster to only evaluate them once.  */
    4998       104252 :       if (TREE_SIDE_EFFECTS (e))
    4999         1008 :         return save_expr (e);
    5000              :       return e;
    5001              : 
    5002              :     case tcc_constant:
    5003              :       /* Constants need no processing.  In fact, we should never reach
    5004              :          here.  */
    5005              :       return e;
    5006              : 
    5007        22178 :     case tcc_binary:
    5008              :       /* Division is slow and tends to be compiled with jumps,
    5009              :          especially the division by powers of 2 that is often
    5010              :          found inside of an array reference.  So do it just once.  */
    5011        22178 :       if (code == TRUNC_DIV_EXPR || code == TRUNC_MOD_EXPR
    5012        20137 :           || code == FLOOR_DIV_EXPR || code == FLOOR_MOD_EXPR
    5013        20137 :           || code == CEIL_DIV_EXPR || code == CEIL_MOD_EXPR
    5014        20137 :           || code == ROUND_DIV_EXPR || code == ROUND_MOD_EXPR)
    5015         2041 :         return save_expr (e);
    5016              :       /* Recursively stabilize each operand.  */
    5017        20137 :       result = build_nt (code, stabilize_reference_1 (TREE_OPERAND (e, 0)),
    5018        20137 :                          stabilize_reference_1 (TREE_OPERAND (e, 1)));
    5019        20137 :       break;
    5020              : 
    5021         7840 :     case tcc_unary:
    5022              :       /* Recursively stabilize each operand.  */
    5023         7840 :       result = build_nt (code, stabilize_reference_1 (TREE_OPERAND (e, 0)));
    5024         7840 :       break;
    5025              : 
    5026            0 :     default:
    5027            0 :       gcc_unreachable ();
    5028              :     }
    5029              : 
    5030        27977 :   TREE_TYPE (result) = TREE_TYPE (e);
    5031        27977 :   TREE_READONLY (result) = TREE_READONLY (e);
    5032        27977 :   TREE_SIDE_EFFECTS (result) = TREE_SIDE_EFFECTS (e);
    5033        27977 :   TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (e);
    5034              : 
    5035        27977 :   return result;
    5036              : }
    5037              : 
    5038              : /* Stabilize a reference so that we can use it any number of times
    5039              :    without causing its operands to be evaluated more than once.
    5040              :    Returns the stabilized reference.  This works by means of save_expr,
    5041              :    so see the caveats in the comments about save_expr.
    5042              : 
    5043              :    Also allows conversion expressions whose operands are references.
    5044              :    Any other kind of expression is returned unchanged.  */
    5045              : 
    5046              : tree
    5047      4888026 : stabilize_reference (tree ref)
    5048              : {
    5049      4888026 :   tree result;
    5050      4888026 :   enum tree_code code = TREE_CODE (ref);
    5051              : 
    5052      4888026 :   switch (code)
    5053              :     {
    5054              :     case VAR_DECL:
    5055              :     case PARM_DECL:
    5056              :     case RESULT_DECL:
    5057              :       /* No action is needed in this case.  */
    5058              :       return ref;
    5059              : 
    5060            0 :     CASE_CONVERT:
    5061            0 :     case FLOAT_EXPR:
    5062            0 :     case FIX_TRUNC_EXPR:
    5063            0 :       result = build_nt (code, stabilize_reference (TREE_OPERAND (ref, 0)));
    5064            0 :       break;
    5065              : 
    5066       806784 :     case INDIRECT_REF:
    5067       806784 :       result = build_nt (INDIRECT_REF,
    5068       806784 :                          stabilize_reference_1 (TREE_OPERAND (ref, 0)));
    5069       806784 :       break;
    5070              : 
    5071       465243 :     case COMPONENT_REF:
    5072       465243 :       result = build_nt (COMPONENT_REF,
    5073       465243 :                          stabilize_reference (TREE_OPERAND (ref, 0)),
    5074       465243 :                          TREE_OPERAND (ref, 1), NULL_TREE);
    5075       465243 :       break;
    5076              : 
    5077            0 :     case BIT_FIELD_REF:
    5078            0 :       result = build_nt (BIT_FIELD_REF,
    5079            0 :                          stabilize_reference (TREE_OPERAND (ref, 0)),
    5080            0 :                          TREE_OPERAND (ref, 1), TREE_OPERAND (ref, 2));
    5081            0 :       REF_REVERSE_STORAGE_ORDER (result) = REF_REVERSE_STORAGE_ORDER (ref);
    5082            0 :       break;
    5083              : 
    5084        47674 :     case ARRAY_REF:
    5085        95348 :       result = build_nt (ARRAY_REF,
    5086        47674 :                          stabilize_reference (TREE_OPERAND (ref, 0)),
    5087        47674 :                          stabilize_reference_1 (TREE_OPERAND (ref, 1)),
    5088        47674 :                          TREE_OPERAND (ref, 2), TREE_OPERAND (ref, 3));
    5089        47674 :       break;
    5090              : 
    5091            0 :     case ARRAY_RANGE_REF:
    5092            0 :       result = build_nt (ARRAY_RANGE_REF,
    5093            0 :                          stabilize_reference (TREE_OPERAND (ref, 0)),
    5094            0 :                          stabilize_reference_1 (TREE_OPERAND (ref, 1)),
    5095            0 :                          TREE_OPERAND (ref, 2), TREE_OPERAND (ref, 3));
    5096            0 :       break;
    5097              : 
    5098            0 :     case COMPOUND_EXPR:
    5099              :       /* We cannot wrap the first expression in a SAVE_EXPR, as then
    5100              :          it wouldn't be ignored.  This matters when dealing with
    5101              :          volatiles.  */
    5102            0 :       return stabilize_reference_1 (ref);
    5103              : 
    5104              :       /* If arg isn't a kind of lvalue we recognize, make no change.
    5105              :          Caller should recognize the error for an invalid lvalue.  */
    5106              :     default:
    5107              :       return ref;
    5108              : 
    5109            0 :     case ERROR_MARK:
    5110            0 :       return error_mark_node;
    5111              :     }
    5112              : 
    5113      1319701 :   TREE_TYPE (result) = TREE_TYPE (ref);
    5114      1319701 :   TREE_READONLY (result) = TREE_READONLY (ref);
    5115      1319701 :   TREE_SIDE_EFFECTS (result) = TREE_SIDE_EFFECTS (ref);
    5116      1319701 :   TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (ref);
    5117      1319701 :   protected_set_expr_location (result, EXPR_LOCATION (ref));
    5118              : 
    5119      1319701 :   return result;
    5120              : }
    5121              : 
    5122              : /* Low-level constructors for expressions.  */
    5123              : 
    5124              : /* A helper function for build1 and constant folders.  Set TREE_CONSTANT,
    5125              :    and TREE_SIDE_EFFECTS for an ADDR_EXPR.  */
    5126              : 
    5127              : void
    5128   1451700712 : recompute_tree_invariant_for_addr_expr (tree t)
    5129              : {
    5130   1451700712 :   tree node;
    5131   1451700712 :   bool tc = true, se = false;
    5132              : 
    5133   1451700712 :   gcc_assert (TREE_CODE (t) == ADDR_EXPR);
    5134              : 
    5135              :   /* We started out assuming this address is both invariant and constant, but
    5136              :      does not have side effects.  Now go down any handled components and see if
    5137              :      any of them involve offsets that are either non-constant or non-invariant.
    5138              :      Also check for side-effects.
    5139              : 
    5140              :      ??? Note that this code makes no attempt to deal with the case where
    5141              :      taking the address of something causes a copy due to misalignment.  */
    5142              : 
    5143              : #define UPDATE_FLAGS(NODE)  \
    5144              : do { tree _node = (NODE); \
    5145              :      if (_node && !TREE_CONSTANT (_node)) tc = false; \
    5146              :      if (_node && TREE_SIDE_EFFECTS (_node)) se = true; } while (0)
    5147              : 
    5148   1700857262 :   for (node = TREE_OPERAND (t, 0); handled_component_p (node);
    5149    249156550 :        node = TREE_OPERAND (node, 0))
    5150              :     {
    5151              :       /* If the first operand doesn't have an ARRAY_TYPE, this is a bogus
    5152              :          array reference (probably made temporarily by the G++ front end),
    5153              :          so ignore all the operands.  */
    5154    249156550 :       if ((TREE_CODE (node) == ARRAY_REF
    5155    249156550 :            || TREE_CODE (node) == ARRAY_RANGE_REF)
    5156    249156550 :           && TREE_CODE (TREE_TYPE (TREE_OPERAND (node, 0))) == ARRAY_TYPE)
    5157              :         {
    5158     34900685 :           UPDATE_FLAGS (TREE_OPERAND (node, 1));
    5159     34900685 :           if (TREE_OPERAND (node, 2))
    5160      2274551 :             UPDATE_FLAGS (TREE_OPERAND (node, 2));
    5161     34900685 :           if (TREE_OPERAND (node, 3))
    5162       310371 :             UPDATE_FLAGS (TREE_OPERAND (node, 3));
    5163              :         }
    5164              :       /* Likewise, just because this is a COMPONENT_REF doesn't mean we have a
    5165              :          FIELD_DECL, apparently.  The G++ front end can put something else
    5166              :          there, at least temporarily.  */
    5167    214255865 :       else if (TREE_CODE (node) == COMPONENT_REF
    5168    214255865 :                && TREE_CODE (TREE_OPERAND (node, 1)) == FIELD_DECL)
    5169              :         {
    5170    213027906 :           if (TREE_OPERAND (node, 2))
    5171        17038 :             UPDATE_FLAGS (TREE_OPERAND (node, 2));
    5172              :         }
    5173              :     }
    5174              : 
    5175   1451700712 :   node = lang_hooks.expr_to_decl (node, &tc, &se);
    5176              : 
    5177              :   /* Now see what's inside.  If it's an INDIRECT_REF, copy our properties from
    5178              :      the address, since &(*a)->b is a form of addition.  If it's a constant, the
    5179              :      address is constant too.  If it's a decl, its address is constant if the
    5180              :      decl is static.  Everything else is not constant and, furthermore,
    5181              :      taking the address of a volatile variable is not volatile.  */
    5182   1451700712 :   if (INDIRECT_REF_P (node)
    5183   1412299581 :       || TREE_CODE (node) == MEM_REF)
    5184    165449840 :     UPDATE_FLAGS (TREE_OPERAND (node, 0));
    5185   1286250872 :   else if (CONSTANT_CLASS_P (node))
    5186              :     ;
    5187   1203818921 :   else if (DECL_P (node))
    5188   1179271430 :     tc &= (staticp (node) != NULL_TREE);
    5189              :   else
    5190              :     {
    5191     24547491 :       tc = false;
    5192     24547491 :       se |= TREE_SIDE_EFFECTS (node);
    5193              :     }
    5194              : 
    5195              : 
    5196   1451700712 :   TREE_CONSTANT (t) = tc;
    5197   1451700712 :   TREE_SIDE_EFFECTS (t) = se;
    5198              : #undef UPDATE_FLAGS
    5199   1451700712 : }
    5200              : 
    5201              : /* Build an expression of code CODE, data type TYPE, and operands as
    5202              :    specified.  Expressions and reference nodes can be created this way.
    5203              :    Constants, decls, types and misc nodes cannot be.
    5204              : 
    5205              :    We define 5 non-variadic functions, from 0 to 4 arguments.  This is
    5206              :    enough for all extant tree codes.  */
    5207              : 
    5208              : tree
    5209    400386305 : build0 (enum tree_code code, tree tt MEM_STAT_DECL)
    5210              : {
    5211    400386305 :   tree t;
    5212              : 
    5213    400386305 :   gcc_assert (TREE_CODE_LENGTH (code) == 0);
    5214              : 
    5215    400386305 :   t = make_node (code PASS_MEM_STAT);
    5216    400386305 :   TREE_TYPE (t) = tt;
    5217              : 
    5218    400386305 :   return t;
    5219              : }
    5220              : 
    5221              : tree
    5222   4137980180 : build1 (enum tree_code code, tree type, tree node MEM_STAT_DECL)
    5223              : {
    5224   4137980180 :   int length = sizeof (struct tree_exp);
    5225   4137980180 :   tree t;
    5226              : 
    5227   4137980180 :   record_node_allocation_statistics (code, length);
    5228              : 
    5229   4137980180 :   gcc_assert (TREE_CODE_LENGTH (code) == 1);
    5230              : 
    5231   4137980180 :   t = ggc_alloc_tree_node_stat (length PASS_MEM_STAT);
    5232              : 
    5233   4137980180 :   memset (t, 0, sizeof (struct tree_common));
    5234              : 
    5235   4137980180 :   TREE_SET_CODE (t, code);
    5236              : 
    5237   4137980180 :   TREE_TYPE (t) = type;
    5238   4137980180 :   SET_EXPR_LOCATION (t, UNKNOWN_LOCATION);
    5239   4137980180 :   TREE_OPERAND (t, 0) = node;
    5240   4137980180 :   if (node && !TYPE_P (node))
    5241              :     {
    5242   4137917105 :       TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (node);
    5243   4137917105 :       TREE_READONLY (t) = TREE_READONLY (node);
    5244              :     }
    5245              : 
    5246   4137980180 :   if (TREE_CODE_CLASS (code) == tcc_statement)
    5247              :     {
    5248     24436126 :       if (code != DEBUG_BEGIN_STMT)
    5249     24436126 :         TREE_SIDE_EFFECTS (t) = 1;
    5250              :     }
    5251   4113544054 :   else switch (code)
    5252              :     {
    5253        51222 :     case VA_ARG_EXPR:
    5254              :       /* All of these have side-effects, no matter what their
    5255              :          operands are.  */
    5256        51222 :       TREE_SIDE_EFFECTS (t) = 1;
    5257        51222 :       TREE_READONLY (t) = 0;
    5258        51222 :       break;
    5259              : 
    5260    642120736 :     case INDIRECT_REF:
    5261              :       /* Whether a dereference is readonly has nothing to do with whether
    5262              :          its operand is readonly.  */
    5263    642120736 :       TREE_READONLY (t) = 0;
    5264    642120736 :       break;
    5265              : 
    5266    692638273 :     case ADDR_EXPR:
    5267    692638273 :       if (node)
    5268    692638273 :         recompute_tree_invariant_for_addr_expr (t);
    5269              :       break;
    5270              : 
    5271   2778733823 :     default:
    5272   1025023712 :       if ((TREE_CODE_CLASS (code) == tcc_unary || code == VIEW_CONVERT_EXPR)
    5273   2629001615 :           && node && !TYPE_P (node)
    5274   5407735438 :           && TREE_CONSTANT (node))
    5275    725856557 :         TREE_CONSTANT (t) = 1;
    5276   2778733823 :       if (TREE_CODE_CLASS (code) == tcc_reference
    5277    878062643 :           && node && TREE_THIS_VOLATILE (node))
    5278      3036105 :         TREE_THIS_VOLATILE (t) = 1;
    5279              :       break;
    5280              :     }
    5281              : 
    5282   4137980180 :   return t;
    5283              : }
    5284              : 
    5285              : #define PROCESS_ARG(N)                          \
    5286              :   do {                                          \
    5287              :     TREE_OPERAND (t, N) = arg##N;               \
    5288              :     if (arg##N &&!TYPE_P (arg##N))              \
    5289              :       {                                         \
    5290              :         if (TREE_SIDE_EFFECTS (arg##N))         \
    5291              :           side_effects = 1;                     \
    5292              :         if (!TREE_READONLY (arg##N)             \
    5293              :             && !CONSTANT_CLASS_P (arg##N))      \
    5294              :           (void) (read_only = 0);               \
    5295              :         if (!TREE_CONSTANT (arg##N))            \
    5296              :           (void) (constant = 0);                \
    5297              :       }                                         \
    5298              :   } while (0)
    5299              : 
    5300              : tree
    5301   1321737916 : build2 (enum tree_code code, tree tt, tree arg0, tree arg1 MEM_STAT_DECL)
    5302              : {
    5303   1321737916 :   bool constant, read_only, side_effects, div_by_zero;
    5304   1321737916 :   tree t;
    5305              : 
    5306   1321737916 :   gcc_assert (TREE_CODE_LENGTH (code) == 2);
    5307              : 
    5308   1321737916 :   if ((code == MINUS_EXPR || code == PLUS_EXPR || code == MULT_EXPR)
    5309    196141652 :       && arg0 && arg1 && tt && POINTER_TYPE_P (tt)
    5310              :       /* When sizetype precision doesn't match that of pointers
    5311              :          we need to be able to build explicit extensions or truncations
    5312              :          of the offset argument.  */
    5313   1321737916 :       && TYPE_PRECISION (sizetype) == TYPE_PRECISION (tt))
    5314            0 :     gcc_assert (TREE_CODE (arg0) == INTEGER_CST
    5315              :                 && TREE_CODE (arg1) == INTEGER_CST);
    5316              : 
    5317   1321737916 :   if (code == POINTER_PLUS_EXPR && arg0 && arg1 && tt)
    5318     62877300 :     gcc_assert (POINTER_TYPE_P (tt) && POINTER_TYPE_P (TREE_TYPE (arg0))
    5319              :                 && ptrofftype_p (TREE_TYPE (arg1)));
    5320              : 
    5321   1321737916 :   t = make_node (code PASS_MEM_STAT);
    5322   1321737916 :   TREE_TYPE (t) = tt;
    5323              : 
    5324              :   /* Below, we automatically set TREE_SIDE_EFFECTS and TREE_READONLY for the
    5325              :      result based on those same flags for the arguments.  But if the
    5326              :      arguments aren't really even `tree' expressions, we shouldn't be trying
    5327              :      to do this.  */
    5328              : 
    5329              :   /* Expressions without side effects may be constant if their
    5330              :      arguments are as well.  */
    5331   2643475832 :   constant = (TREE_CODE_CLASS (code) == tcc_comparison
    5332   1321737916 :               || TREE_CODE_CLASS (code) == tcc_binary);
    5333   1321737916 :   read_only = 1;
    5334   1321737916 :   side_effects = TREE_SIDE_EFFECTS (t);
    5335              : 
    5336   1321737916 :   switch (code)
    5337              :     {
    5338     14621233 :     case TRUNC_DIV_EXPR:
    5339     14621233 :     case CEIL_DIV_EXPR:
    5340     14621233 :     case FLOOR_DIV_EXPR:
    5341     14621233 :     case ROUND_DIV_EXPR:
    5342     14621233 :     case EXACT_DIV_EXPR:
    5343     14621233 :     case CEIL_MOD_EXPR:
    5344     14621233 :     case FLOOR_MOD_EXPR:
    5345     14621233 :     case ROUND_MOD_EXPR:
    5346     14621233 :     case TRUNC_MOD_EXPR:
    5347     14621233 :       div_by_zero = integer_zerop (arg1);
    5348     14621233 :       break;
    5349              :     default:
    5350              :       div_by_zero = false;
    5351              :     }
    5352              : 
    5353   1463170031 :   PROCESS_ARG (0);
    5354   1864717089 :   PROCESS_ARG (1);
    5355              : 
    5356   1321737916 :   TREE_SIDE_EFFECTS (t) = side_effects;
    5357   1321737916 :   if (code == MEM_REF)
    5358              :     {
    5359     83086980 :       if (arg0 && TREE_CODE (arg0) == ADDR_EXPR)
    5360              :         {
    5361     23558702 :           tree o = TREE_OPERAND (arg0, 0);
    5362     23558702 :           TREE_READONLY (t) = TREE_READONLY (o);
    5363     23558702 :           TREE_THIS_VOLATILE (t) = TREE_THIS_VOLATILE (o);
    5364              :         }
    5365              :     }
    5366              :   else
    5367              :     {
    5368   1238650936 :       TREE_READONLY (t) = read_only;
    5369              :       /* Don't mark X / 0 as constant.  */
    5370   1238650936 :       TREE_CONSTANT (t) = constant && !div_by_zero;
    5371   1238650936 :       TREE_THIS_VOLATILE (t)
    5372   1238650936 :         = (TREE_CODE_CLASS (code) == tcc_reference
    5373   1238650936 :            && arg0 && TREE_THIS_VOLATILE (arg0));
    5374              :     }
    5375              : 
    5376   1321737916 :   return t;
    5377              : }
    5378              : 
    5379              : 
    5380              : tree
    5381    486300196 : build3 (enum tree_code code, tree tt, tree arg0, tree arg1,
    5382              :         tree arg2 MEM_STAT_DECL)
    5383              : {
    5384    486300196 :   bool constant, read_only, side_effects;
    5385    486300196 :   tree t;
    5386              : 
    5387    486300196 :   gcc_assert (TREE_CODE_LENGTH (code) == 3);
    5388    486300196 :   gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp);
    5389              : 
    5390    486300196 :   t = make_node (code PASS_MEM_STAT);
    5391    486300196 :   TREE_TYPE (t) = tt;
    5392              : 
    5393    486300196 :   read_only = 1;
    5394              : 
    5395              :   /* As a special exception, if COND_EXPR has NULL branches, we
    5396              :      assume that it is a gimple statement and always consider
    5397              :      it to have side effects.  */
    5398    486300196 :   if (code == COND_EXPR
    5399     40889274 :       && tt == void_type_node
    5400     25589991 :       && arg1 == NULL_TREE
    5401     25589991 :       && arg2 == NULL_TREE)
    5402              :     side_effects = true;
    5403              :   else
    5404    486300196 :     side_effects = TREE_SIDE_EFFECTS (t);
    5405              : 
    5406    486300196 :   PROCESS_ARG (0);
    5407    486300196 :   PROCESS_ARG (1);
    5408    486300196 :   PROCESS_ARG (2);
    5409              : 
    5410    486300196 :   if (code == COND_EXPR)
    5411     40889274 :     TREE_READONLY (t) = read_only;
    5412              : 
    5413    486300196 :   TREE_SIDE_EFFECTS (t) = side_effects;
    5414    486300196 :   TREE_THIS_VOLATILE (t)
    5415    486300196 :     = (TREE_CODE_CLASS (code) == tcc_reference
    5416    486300196 :        && arg0 && TREE_THIS_VOLATILE (arg0));
    5417              : 
    5418    486300196 :   return t;
    5419              : }
    5420              : 
    5421              : tree
    5422     59505008 : build4 (enum tree_code code, tree tt, tree arg0, tree arg1,
    5423              :         tree arg2, tree arg3 MEM_STAT_DECL)
    5424              : {
    5425     59505008 :   bool constant, read_only, side_effects;
    5426     59505008 :   tree t;
    5427              : 
    5428     59505008 :   gcc_assert (TREE_CODE_LENGTH (code) == 4);
    5429              : 
    5430     59505008 :   t = make_node (code PASS_MEM_STAT);
    5431     59505008 :   TREE_TYPE (t) = tt;
    5432              : 
    5433     59505008 :   side_effects = TREE_SIDE_EFFECTS (t);
    5434              : 
    5435     59505008 :   PROCESS_ARG (0);
    5436     59505008 :   PROCESS_ARG (1);
    5437     59505008 :   PROCESS_ARG (2);
    5438     59505008 :   PROCESS_ARG (3);
    5439              : 
    5440     59505008 :   TREE_SIDE_EFFECTS (t) = side_effects;
    5441     59505008 :   TREE_THIS_VOLATILE (t)
    5442    119010016 :     = (TREE_CODE_CLASS (code) == tcc_reference
    5443     59505008 :        && arg0 && TREE_THIS_VOLATILE (arg0));
    5444              : 
    5445     59505008 :   return t;
    5446              : }
    5447              : 
    5448              : tree
    5449      1174632 : build5 (enum tree_code code, tree tt, tree arg0, tree arg1,
    5450              :         tree arg2, tree arg3, tree arg4 MEM_STAT_DECL)
    5451              : {
    5452      1174632 :   bool constant, read_only, side_effects;
    5453      1174632 :   tree t;
    5454              : 
    5455      1174632 :   gcc_assert (TREE_CODE_LENGTH (code) == 5);
    5456              : 
    5457      1174632 :   t = make_node (code PASS_MEM_STAT);
    5458      1174632 :   TREE_TYPE (t) = tt;
    5459              : 
    5460      1174632 :   side_effects = TREE_SIDE_EFFECTS (t);
    5461              : 
    5462      1174632 :   PROCESS_ARG (0);
    5463      1174632 :   PROCESS_ARG (1);
    5464      1174632 :   PROCESS_ARG (2);
    5465      1174632 :   PROCESS_ARG (3);
    5466      1174632 :   PROCESS_ARG (4);
    5467              : 
    5468      1174632 :   TREE_SIDE_EFFECTS (t) = side_effects;
    5469      1174632 :   if (code == TARGET_MEM_REF)
    5470              :     {
    5471      1165692 :       if (arg0 && TREE_CODE (arg0) == ADDR_EXPR)
    5472              :         {
    5473       184329 :           tree o = TREE_OPERAND (arg0, 0);
    5474       184329 :           TREE_READONLY (t) = TREE_READONLY (o);
    5475       184329 :           TREE_THIS_VOLATILE (t) = TREE_THIS_VOLATILE (o);
    5476              :         }
    5477              :     }
    5478              :   else
    5479         8940 :     TREE_THIS_VOLATILE (t)
    5480         8940 :       = (TREE_CODE_CLASS (code) == tcc_reference
    5481         8940 :          && arg0 && TREE_THIS_VOLATILE (arg0));
    5482              : 
    5483      1174632 :   return t;
    5484              : }
    5485              : 
    5486              : /* Build a simple MEM_REF tree with the semantics of a plain INDIRECT_REF
    5487              :    on the pointer PTR.  */
    5488              : 
    5489              : tree
    5490       485294 : build_simple_mem_ref_loc (location_t loc, tree ptr)
    5491              : {
    5492       485294 :   poly_int64 offset = 0;
    5493       485294 :   tree ptype = TREE_TYPE (ptr);
    5494       485294 :   tree tem;
    5495              :   /* For convenience allow addresses that collapse to a simple base
    5496              :      and offset.  */
    5497       485294 :   if (TREE_CODE (ptr) == ADDR_EXPR
    5498       485294 :       && (handled_component_p (TREE_OPERAND (ptr, 0))
    5499        15617 :           || TREE_CODE (TREE_OPERAND (ptr, 0)) == MEM_REF))
    5500              :     {
    5501          147 :       ptr = get_addr_base_and_unit_offset (TREE_OPERAND (ptr, 0), &offset);
    5502          147 :       gcc_assert (ptr);
    5503          147 :       if (TREE_CODE (ptr) == MEM_REF)
    5504              :         {
    5505           37 :           offset += mem_ref_offset (ptr).force_shwi ();
    5506           37 :           ptr = TREE_OPERAND (ptr, 0);
    5507              :         }
    5508              :       else
    5509          110 :         ptr = build_fold_addr_expr (ptr);
    5510          147 :       gcc_assert (is_gimple_reg (ptr) || is_gimple_min_invariant (ptr));
    5511              :     }
    5512       485294 :   tem = build2 (MEM_REF, TREE_TYPE (ptype),
    5513              :                 ptr, build_int_cst (ptype, offset));
    5514       485294 :   SET_EXPR_LOCATION (tem, loc);
    5515       485294 :   return tem;
    5516              : }
    5517              : 
    5518              : /* Return the constant offset of a MEM_REF or TARGET_MEM_REF tree T.  */
    5519              : 
    5520              : poly_offset_int
    5521   1237236330 : mem_ref_offset (const_tree t)
    5522              : {
    5523   1237236330 :   return poly_offset_int::from (wi::to_poly_wide (TREE_OPERAND (t, 1)),
    5524   1237236330 :                                 SIGNED);
    5525              : }
    5526              : 
    5527              : /* Return an invariant ADDR_EXPR of type TYPE taking the address of BASE
    5528              :    offsetted by OFFSET units.  */
    5529              : 
    5530              : tree
    5531       202166 : build_invariant_address (tree type, tree base, poly_int64 offset)
    5532              : {
    5533       202166 :   tree ref = fold_build2 (MEM_REF, TREE_TYPE (type),
    5534              :                           build_fold_addr_expr (base),
    5535              :                           build_int_cst (ptr_type_node, offset));
    5536       202166 :   tree addr = build1 (ADDR_EXPR, type, ref);
    5537       202166 :   recompute_tree_invariant_for_addr_expr (addr);
    5538       202166 :   return addr;
    5539              : }
    5540              : 
    5541              : /* Similar except don't specify the TREE_TYPE
    5542              :    and leave the TREE_SIDE_EFFECTS as 0.
    5543              :    It is permissible for arguments to be null,
    5544              :    or even garbage if their values do not matter.  */
    5545              : 
    5546              : tree
    5547      5760706 : build_nt (enum tree_code code, ...)
    5548              : {
    5549      5760706 :   tree t;
    5550      5760706 :   int length;
    5551      5760706 :   int i;
    5552      5760706 :   va_list p;
    5553              : 
    5554      5760706 :   gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp);
    5555              : 
    5556      5760706 :   va_start (p, code);
    5557              : 
    5558      5760706 :   t = make_node (code);
    5559      5760706 :   length = TREE_CODE_LENGTH (code);
    5560              : 
    5561     17077384 :   for (i = 0; i < length; i++)
    5562     11316678 :     TREE_OPERAND (t, i) = va_arg (p, tree);
    5563              : 
    5564      5760706 :   va_end (p);
    5565      5760706 :   return t;
    5566              : }
    5567              : 
    5568              : /* Similar to build_nt, but for creating a CALL_EXPR object with a
    5569              :    tree vec.  */
    5570              : 
    5571              : tree
    5572            0 : build_nt_call_vec (tree fn, vec<tree, va_gc> *args)
    5573              : {
    5574            0 :   tree ret, t;
    5575            0 :   unsigned int ix;
    5576              : 
    5577            0 :   ret = build_vl_exp (CALL_EXPR, vec_safe_length (args) + 3);
    5578            0 :   CALL_EXPR_FN (ret) = fn;
    5579            0 :   CALL_EXPR_STATIC_CHAIN (ret) = NULL_TREE;
    5580            0 :   FOR_EACH_VEC_SAFE_ELT (args, ix, t)
    5581            0 :     CALL_EXPR_ARG (ret, ix) = t;
    5582            0 :   return ret;
    5583              : }
    5584              : 
    5585              : /* Create a DECL_... node of code CODE, name NAME  (if non-null)
    5586              :    and data type TYPE.
    5587              :    We do NOT enter this node in any sort of symbol table.
    5588              : 
    5589              :    LOC is the location of the decl.
    5590              : 
    5591              :    layout_decl is used to set up the decl's storage layout.
    5592              :    Other slots are initialized to 0 or null pointers.  */
    5593              : 
    5594              : tree
    5595   3306215869 : build_decl (location_t loc, enum tree_code code, tree name,
    5596              :                  tree type MEM_STAT_DECL)
    5597              : {
    5598   3306215869 :   tree t;
    5599              : 
    5600   3306215869 :   t = make_node (code PASS_MEM_STAT);
    5601   3306215869 :   DECL_SOURCE_LOCATION (t) = loc;
    5602              : 
    5603              : /*  if (type == error_mark_node)
    5604              :     type = integer_type_node; */
    5605              : /* That is not done, deliberately, so that having error_mark_node
    5606              :    as the type can suppress useless errors in the use of this variable.  */
    5607              : 
    5608   3306215869 :   DECL_NAME (t) = name;
    5609   3306215869 :   TREE_TYPE (t) = type;
    5610              : 
    5611   3306215869 :   if (code == VAR_DECL || code == PARM_DECL || code == RESULT_DECL)
    5612   1166525586 :     layout_decl (t, 0);
    5613              : 
    5614   3306215869 :   return t;
    5615              : }
    5616              : 
    5617              : /* Create and return a DEBUG_EXPR_DECL node of the given TYPE.  */
    5618              : 
    5619              : tree
    5620      1731304 : build_debug_expr_decl (tree type)
    5621              : {
    5622      1731304 :   tree vexpr = make_node (DEBUG_EXPR_DECL);
    5623      1731304 :   DECL_ARTIFICIAL (vexpr) = 1;
    5624      1731304 :   TREE_TYPE (vexpr) = type;
    5625      1731304 :   SET_DECL_MODE (vexpr, TYPE_MODE (type));
    5626      1731304 :   return vexpr;
    5627              : }
    5628              : 
    5629              : /* Builds and returns function declaration with NAME and TYPE.  */
    5630              : 
    5631              : tree
    5632        21475 : build_fn_decl (const char *name, tree type)
    5633              : {
    5634        21475 :   tree id = get_identifier (name);
    5635        21475 :   tree decl = build_decl (input_location, FUNCTION_DECL, id, type);
    5636              : 
    5637        21475 :   DECL_EXTERNAL (decl) = 1;
    5638        21475 :   TREE_PUBLIC (decl) = 1;
    5639        21475 :   DECL_ARTIFICIAL (decl) = 1;
    5640        21475 :   TREE_NOTHROW (decl) = 1;
    5641              : 
    5642        21475 :   return decl;
    5643              : }
    5644              : 
    5645              : vec<tree, va_gc> *all_translation_units;
    5646              : 
    5647              : /* Builds a new translation-unit decl with name NAME, queues it in the
    5648              :    global list of translation-unit decls and returns it.   */
    5649              : 
    5650              : tree
    5651       258988 : build_translation_unit_decl (tree name)
    5652              : {
    5653       258988 :   tree tu = build_decl (UNKNOWN_LOCATION, TRANSLATION_UNIT_DECL,
    5654       258988 :                         name, NULL_TREE);
    5655       258988 :   TRANSLATION_UNIT_LANGUAGE (tu) = lang_hooks.name;
    5656       258988 :   vec_safe_push (all_translation_units, tu);
    5657       258988 :   return tu;
    5658              : }
    5659              : 
    5660              : 
    5661              : /* BLOCK nodes are used to represent the structure of binding contours
    5662              :    and declarations, once those contours have been exited and their contents
    5663              :    compiled.  This information is used for outputting debugging info.  */
    5664              : 
    5665              : tree
    5666       748799 : build_block (tree vars, tree subblocks, tree supercontext, tree chain)
    5667              : {
    5668       748799 :   tree block = make_node (BLOCK);
    5669              : 
    5670       748799 :   BLOCK_VARS (block) = vars;
    5671       748799 :   BLOCK_SUBBLOCKS (block) = subblocks;
    5672       748799 :   BLOCK_SUPERCONTEXT (block) = supercontext;
    5673       748799 :   BLOCK_CHAIN (block) = chain;
    5674       748799 :   return block;
    5675              : }
    5676              : 
    5677              : 
    5678              : /* Like SET_EXPR_LOCATION, but make sure the tree can have a location.
    5679              : 
    5680              :    LOC is the location to use in tree T.  */
    5681              : 
    5682              : void
    5683  14936688862 : protected_set_expr_location (tree t, location_t loc)
    5684              : {
    5685  14936688862 :   if (CAN_HAVE_LOCATION_P (t))
    5686   2369150951 :     SET_EXPR_LOCATION (t, loc);
    5687  12477495601 :   else if (t && TREE_CODE (t) == STATEMENT_LIST)
    5688              :     {
    5689        22265 :       t = expr_single (t);
    5690        22265 :       if (t && CAN_HAVE_LOCATION_P (t))
    5691           18 :         SET_EXPR_LOCATION (t, loc);
    5692              :     }
    5693  14936688862 : }
    5694              : 
    5695              : /* Like PROTECTED_SET_EXPR_LOCATION, but only do that if T has
    5696              :    UNKNOWN_LOCATION.  */
    5697              : 
    5698              : void
    5699     26462639 : protected_set_expr_location_if_unset (tree t, location_t loc)
    5700              : {
    5701     26462639 :   t = expr_single (t);
    5702     26462639 :   if (t && !EXPR_HAS_LOCATION (t))
    5703     17204188 :     protected_set_expr_location (t, loc);
    5704     26462639 : }
    5705              : 
    5706              : 
    5707              : /* Attempt to produce a qualifier_set that's a merge of qualifiers in THIS and
    5708              :    OTHER.  Such a qualifier set can be used instead of either THIS or OTHER
    5709              :    safely.  (i.e. if a type was qualified by either THIS or OTHER, it can be
    5710              :    qualified by their merge instead safely, possibly through a conversion)
    5711              : 
    5712              :    This operation may fail.  In that case, the error value returned provides
    5713              :    reasoning for the failure.
    5714              : 
    5715              :    If STRICT_ADDR_SPACE, then no address space mismatch is permitted.  This is
    5716              :    useful if merging below the top-level of pointers (i.e. in a case such as
    5717              :    'AS1 T**' vs 'AS2 T**').
    5718              : 
    5719              :    You'll need to include stdbackport/expected to use this.  */
    5720              : 
    5721              : gcc::expected<qualifier_set, qualifier_set::merge_error>
    5722            0 : qualifier_set::merge (qualifier_set other,
    5723              :                       bool strict_addr_space /* = false */) const
    5724              : {
    5725            0 :   using ME = qualifier_set::merge_error;
    5726              : 
    5727            0 :   if (has (TYPE_QUAL_ATOMIC) != other.has (TYPE_QUAL_ATOMIC))
    5728            0 :     return gcc::make_unexpected (ME::atomic_mismatch);
    5729              : 
    5730            0 :   auto cv_merged = cv_quals () | other.cv_quals ();
    5731            0 :   auto as1 = addr_space ();
    5732            0 :   auto as2 = other.addr_space ();
    5733              : 
    5734            0 :   addr_space_t as_super;
    5735            0 :   if (as1 == as2)
    5736              :     as_super = as1;
    5737            0 :   else if (!strict_addr_space
    5738            0 :            && targetm.addr_space.subset_p (as1, as2))
    5739              :     as_super = as2;
    5740            0 :   else if (!strict_addr_space
    5741            0 :            && targetm.addr_space.subset_p (as2, as1))
    5742              :     as_super = as1;
    5743              :   else
    5744            0 :     return gcc::make_unexpected (ME::disjoint_address_spaces);
    5745              : 
    5746            0 :   return qualifier_set {cv_merged, as_super};
    5747              : }
    5748              : 
    5749              : /* Return a qualifier set that has all the qualifiers of THIS and OTHER.
    5750              :    Unlike 'merge', this operation operates purely syntactically; if THIS is
    5751              :    {q1_1, q1_2, ..., q1_i} and OTHER {q2_1, q2_2, ..., q2_j}, then returns the
    5752              :    qualifier set obtained by concatenating the sequences q1 and q2 without
    5753              :    duplicates, if such a qualifier set is valid.
    5754              : 
    5755              :    Specifically, this implies that if THIS or OTHER both (syntactically)
    5756              :    contain an address space qualifier, and they're different, the operation
    5757              :    fails (even if one is subset of the other).
    5758              : 
    5759              :    This operation may fail.  In that case, the error value returned provides
    5760              :    reasoning for the failure.
    5761              : 
    5762              :    You'll need to include stdbackport/expected to use this.  */
    5763              : 
    5764              : gcc::expected<qualifier_set, qualifier_set::join_error>
    5765            0 : qualifier_set::join (qualifier_set other) const
    5766              : {
    5767            0 :   using JE = qualifier_set::join_error;
    5768            0 :   auto cv_merged = cv_quals () | other.cv_quals ();
    5769            0 :   auto as1 = addr_space ();
    5770            0 :   auto as2 = other.addr_space ();
    5771              : 
    5772            0 :   addr_space_t as = ADDR_SPACE_GENERIC;
    5773            0 :   if (as1 == as2)
    5774              :     as = as1;
    5775            0 :   else if (!ADDR_SPACE_GENERIC_P (as1) && !ADDR_SPACE_GENERIC_P (as2))
    5776            0 :     return gcc::make_unexpected (JE::double_addr_space);
    5777            0 :   else if (ADDR_SPACE_GENERIC_P (as1))
    5778              :     as = as2;
    5779              :   else
    5780            0 :     as = as1;
    5781              : 
    5782            0 :   return qualifier_set {cv_merged, as};
    5783              : }
    5784              : 
    5785              : /* Returns true if qualifiers in OTHER can be replaced with qualifiers in THIS
    5786              :    safely.
    5787              : 
    5788              :    If !POINTEE, such a replacement is safe iff 'cv2 int *' can be converted
    5789              :    into 'cv1 int *' where cv1 are the qualifiers in THIS and cv2 the qualifiers
    5790              :    in OTHER.
    5791              : 
    5792              :    Otherwise, such a replacement is safe iff 'cv2 int * const *' can be
    5793              :    converted into 'cv1 int * const *' with cv1 and cv2 as above.  */
    5794              : 
    5795              : bool
    5796          182 : qualifier_set::superset_of (qualifier_set other,
    5797              :                             bool pointee /* = false */) const
    5798              : {
    5799              :   /* Compatible if THIS contains all of CVR of OTHER, has the same value of
    5800              :      the _Atomic qualifier as OTHER, and has a superset address space.
    5801              : 
    5802              :      If POINTEE, then it must be possible to reinterpret the value of one
    5803              :      qualification as a value of the other qualification, and thus, the
    5804              :      address spaces must be strictly equal.  */
    5805          182 :   auto cv_this = cv_quals ();
    5806          182 :   auto cv_other = other.cv_quals ();
    5807          182 :   auto as_this = addr_space ();
    5808          182 :   auto as_other = other.addr_space ();
    5809          182 :   return ((cv_this & cv_other) == cv_other
    5810              :           /* Differences in the _Atomic qualifier cannot be crossed.  */
    5811           86 :           && (cv_this & TYPE_QUAL_ATOMIC) == (cv_other & TYPE_QUAL_ATOMIC)
    5812          268 :           && (as_this == as_other
    5813            0 :               || (!pointee
    5814            0 :                   && targetm.addr_space.subset_p (as_other, as_this))));
    5815              : }
    5816              : 
    5817              : DEBUG_FUNCTION void
    5818            0 : qualifier_set::debug () const
    5819              : {
    5820            0 :   putc ('{', stderr);
    5821            0 :   cv_qualifier cv;
    5822            0 :   addr_space_t as;
    5823            0 :   std::tie (cv, as) = split ();
    5824            0 :   bool has_previous = false;
    5825            0 :   auto handle_bit = [&] (cv_qualifier bit, const char *lbl)
    5826              :   {
    5827            0 :     if (!(cv & bit))
    5828              :       return;
    5829              : 
    5830            0 :     if (has_previous)
    5831            0 :       fputs (", ", stderr);
    5832              : 
    5833            0 :     has_previous = true;
    5834            0 :     fputs (lbl, stderr);
    5835            0 :   };
    5836              : 
    5837            0 :   handle_bit (TYPE_QUAL_CONST, "const");
    5838            0 :   handle_bit (TYPE_QUAL_VOLATILE, "volatile");
    5839            0 :   handle_bit (TYPE_QUAL_RESTRICT, "restrict");
    5840            0 :   handle_bit (TYPE_QUAL_ATOMIC, "_Atomic");
    5841              : 
    5842              :   /* If new bits appear, let the developer know.  */
    5843            0 :   static_assert ((TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT
    5844              :                   | TYPE_QUAL_ATOMIC)
    5845              :                  == TYPE_QUAL_ALL,
    5846              :                 "new qualifiers added, update handle_bit calls above");
    5847              : 
    5848            0 :   if (has_previous)
    5849            0 :     fputs (", ", stderr);
    5850              : 
    5851            0 :   fprintf (stderr, "AS%d", as);
    5852              : 
    5853            0 :   fputs ("}\n", stderr);
    5854            0 : }
    5855              : 
    5856              : /* Set the type qualifiers for TYPE to TYPE_QUALS.  */
    5857              : 
    5858              : static void
    5859    113845628 : set_type_quals (tree type, qualifier_set type_quals)
    5860              : {
    5861    113845628 :   TYPE_READONLY (type) = type_quals.has (TYPE_QUAL_CONST);
    5862    113845628 :   TYPE_VOLATILE (type) = type_quals.has (TYPE_QUAL_VOLATILE);
    5863    113845628 :   TYPE_RESTRICT (type) = type_quals.has (TYPE_QUAL_RESTRICT);
    5864    113845628 :   TYPE_ATOMIC (type) = type_quals.has (TYPE_QUAL_ATOMIC);
    5865    113845628 :   TYPE_ADDR_SPACE (type) = type_quals.addr_space ();
    5866    113845628 : }
    5867              : 
    5868              : /* Returns true iff CAND and BASE have equivalent language-specific
    5869              :    qualifiers.  */
    5870              : 
    5871              : bool
    5872   3265324975 : check_lang_type (const_tree cand, const_tree base)
    5873              : {
    5874   3265324975 :   if (lang_hooks.types.type_hash_eq == NULL)
    5875              :     return true;
    5876              :   /* type_hash_eq currently only applies to these types.  */
    5877   3206844322 :   if (TREE_CODE (cand) != FUNCTION_TYPE
    5878   3206844322 :       && TREE_CODE (cand) != METHOD_TYPE)
    5879              :     return true;
    5880      1177155 :   return lang_hooks.types.type_hash_eq (cand, base);
    5881              : }
    5882              : 
    5883              : /* This function checks to see if TYPE matches the size one of the built-in
    5884              :    atomic types, and returns that core atomic type.  */
    5885              : 
    5886              : static tree
    5887         8950 : find_atomic_core_type (const_tree type)
    5888              : {
    5889         8950 :   tree base_atomic_type;
    5890              : 
    5891              :   /* Only handle complete types.  */
    5892         8950 :   if (!tree_fits_uhwi_p (TYPE_SIZE (type)))
    5893              :     return NULL_TREE;
    5894              : 
    5895         8938 :   switch (tree_to_uhwi (TYPE_SIZE (type)))
    5896              :     {
    5897         2724 :     case 8:
    5898         2724 :       base_atomic_type = atomicQI_type_node;
    5899         2724 :       break;
    5900              : 
    5901          866 :     case 16:
    5902          866 :       base_atomic_type = atomicHI_type_node;
    5903          866 :       break;
    5904              : 
    5905         1123 :     case 32:
    5906         1123 :       base_atomic_type = atomicSI_type_node;
    5907         1123 :       break;
    5908              : 
    5909         2757 :     case 64:
    5910         2757 :       base_atomic_type = atomicDI_type_node;
    5911         2757 :       break;
    5912              : 
    5913         1348 :     case 128:
    5914         1348 :       base_atomic_type = atomicTI_type_node;
    5915         1348 :       break;
    5916              : 
    5917              :     default:
    5918              :       base_atomic_type = NULL_TREE;
    5919              :     }
    5920              : 
    5921              :   return base_atomic_type;
    5922              : }
    5923              : 
    5924              : /* Returns true iff unqualified CAND and BASE are equivalent.  */
    5925              : 
    5926              : bool
    5927   5178195091 : check_base_type (const_tree cand, const_tree base)
    5928              : {
    5929   5178195091 :   if (TYPE_NAME (cand) != TYPE_NAME (base)
    5930              :       /* Apparently this is needed for Objective-C.  */
    5931   4559339877 :       || TYPE_CONTEXT (cand) != TYPE_CONTEXT (base)
    5932   9737534967 :       || !attribute_list_equal (TYPE_ATTRIBUTES (cand),
    5933   4559339876 :                                 TYPE_ATTRIBUTES (base)))
    5934              :     return false;
    5935              :   /* Check alignment.  */
    5936   4559339876 :   if (TYPE_ALIGN (cand) == TYPE_ALIGN (base)
    5937   4559339876 :       && TYPE_USER_ALIGN (cand) == TYPE_USER_ALIGN (base))
    5938              :     return true;
    5939              :   /* Atomic types increase minimal alignment.  We must to do so as well
    5940              :      or we get duplicated canonical types. See PR88686.  */
    5941        11297 :   if (TYPE_QUALS (cand).has (TYPE_QUAL_ATOMIC))
    5942              :     {
    5943              :       /* See if this object can map to a basic atomic type.  */
    5944         1775 :       tree atomic_type = find_atomic_core_type (cand);
    5945         1775 :       if (atomic_type && TYPE_ALIGN (atomic_type) == TYPE_ALIGN (cand))
    5946         1775 :        return true;
    5947              :     }
    5948              :   return false;
    5949              : }
    5950              : 
    5951              : /* Returns true iff CAND is equivalent to BASE with TYPE_QUALS.  */
    5952              : 
    5953              : bool
    5954   5554767616 : check_qualified_type (const_tree cand, const_tree base, qualifier_set type_quals)
    5955              : {
    5956   5554767616 :   return (TYPE_QUALS (cand) == type_quals
    5957   3881991531 :           && check_base_type (cand, base)
    5958   3263484228 :           && check_lang_type (cand, base));
    5959              : }
    5960              : 
    5961              : /* Returns true iff CAND is equivalent to BASE with ALIGN.  */
    5962              : 
    5963              : static bool
    5964      3836415 : check_aligned_type (const_tree cand, const_tree base, unsigned int align)
    5965              : {
    5966      3836415 :   return (TYPE_QUALS (cand) == TYPE_QUALS (base)
    5967      3132631 :           && TYPE_NAME (cand) == TYPE_NAME (base)
    5968              :           /* Apparently this is needed for Objective-C.  */
    5969      2225974 :           && TYPE_CONTEXT (cand) == TYPE_CONTEXT (base)
    5970              :           /* Check alignment.  */
    5971      2225974 :           && TYPE_ALIGN (cand) == align
    5972              :           /* Check this is a user-aligned type as build_aligned_type
    5973              :              would create.  */
    5974      1051689 :           && TYPE_USER_ALIGN (cand)
    5975      1048797 :           && attribute_list_equal (TYPE_ATTRIBUTES (cand),
    5976      1048797 :                                    TYPE_ATTRIBUTES (base))
    5977      1048797 :           && check_lang_type (cand, base));
    5978              : }
    5979              : 
    5980              : /* Return a version of the TYPE, qualified as indicated by the
    5981              :    TYPE_QUALS, if one exists.  If no qualified version exists yet,
    5982              :    return NULL_TREE.  */
    5983              : 
    5984              : tree
    5985   4778916284 : get_qualified_type (tree type, qualifier_set type_quals)
    5986              : {
    5987   4778916284 :   if (TYPE_QUALS (type) == type_quals)
    5988              :     return type;
    5989              : 
    5990   3377482593 :   tree mv = TYPE_MAIN_VARIANT (type);
    5991   3377482593 :   if (check_qualified_type (mv, type, type_quals))
    5992              :     return mv;
    5993              : 
    5994              :   /* Search the chain of variants to see if there is already one there just
    5995              :      like the one we need to have.  If so, use that existing one.  We must
    5996              :      preserve the TYPE_NAME, since there is code that depends on this.  */
    5997   2291294040 :   for (tree *tp = &TYPE_NEXT_VARIANT (mv); *tp; tp = &TYPE_NEXT_VARIANT (*tp))
    5998   2177220970 :     if (check_qualified_type (*tp, type, type_quals))
    5999              :       {
    6000              :         /* Put the found variant at the head of the variant list so
    6001              :            frequently searched variants get found faster.  The C++ FE
    6002              :            benefits greatly from this.  */
    6003   1367789159 :         tree t = *tp;
    6004   1367789159 :         *tp = TYPE_NEXT_VARIANT (t);
    6005   1367789159 :         TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (mv);
    6006   1367789159 :         TYPE_NEXT_VARIANT (mv) = t;
    6007   1367789159 :         return t;
    6008              :       }
    6009              : 
    6010              :   return NULL_TREE;
    6011              : }
    6012              : 
    6013              : /* Like get_qualified_type, but creates the type if it does not
    6014              :    exist.  This function never returns NULL_TREE.  */
    6015              : 
    6016              : tree
    6017   4283570805 : build_qualified_type (tree type, qualifier_set type_quals MEM_STAT_DECL)
    6018              : {
    6019   4283570805 :   tree t;
    6020              : 
    6021              :   /* See if we already have the appropriate qualified variant.  */
    6022   4283570805 :   t = get_qualified_type (type, type_quals);
    6023              : 
    6024              :   /* If not, build it.  */
    6025   4283570805 :   if (!t)
    6026              :     {
    6027    112361233 :       t = build_variant_type_copy (type PASS_MEM_STAT);
    6028    112361233 :       set_type_quals (t, type_quals);
    6029              : 
    6030    112361233 :       if (type_quals.has (TYPE_QUAL_ATOMIC))
    6031              :         {
    6032              :           /* See if this object can map to a basic atomic type.  */
    6033         7175 :           tree atomic_type = find_atomic_core_type (type);
    6034         7175 :           if (atomic_type)
    6035              :             {
    6036              :               /* Ensure the alignment of this type is compatible with
    6037              :                  the required alignment of the atomic type.  */
    6038         7043 :               if (TYPE_ALIGN (atomic_type) > TYPE_ALIGN (t))
    6039           98 :                 SET_TYPE_ALIGN (t, TYPE_ALIGN (atomic_type));
    6040              :             }
    6041              :         }
    6042              : 
    6043    112361233 :       if (TYPE_STRUCTURAL_EQUALITY_P (type))
    6044              :         /* Propagate structural equality. */
    6045      5729749 :         SET_TYPE_STRUCTURAL_EQUALITY (t);
    6046    106631484 :       else if (TYPE_CANONICAL (type) != type)
    6047              :         /* Build the underlying canonical type, since it is different
    6048              :            from TYPE. */
    6049              :         {
    6050     34809488 :           tree c = build_qualified_type (TYPE_CANONICAL (type), type_quals);
    6051     34809488 :           TYPE_CANONICAL (t) = TYPE_CANONICAL (c);
    6052              :         }
    6053              :       else
    6054              :         /* T is its own canonical type. */
    6055     71821996 :         TYPE_CANONICAL (t) = t;
    6056              : 
    6057              :     }
    6058              : 
    6059   4283570805 :   return t;
    6060              : }
    6061              : 
    6062              : /* Create a variant of type T with alignment ALIGN which
    6063              :    is measured in bits.  */
    6064              : 
    6065              : tree
    6066      1345336 : build_aligned_type (tree type, unsigned int align)
    6067              : {
    6068      1345336 :   tree t;
    6069              : 
    6070      1345336 :   if (TYPE_PACKED (type)
    6071      1345336 :       || TYPE_ALIGN (type) == align)
    6072              :     return type;
    6073              : 
    6074      3946543 :   for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
    6075      3836415 :     if (check_aligned_type (t, type, align))
    6076              :       return t;
    6077              : 
    6078       110128 :   t = build_variant_type_copy (type);
    6079       110128 :   SET_TYPE_ALIGN (t, align);
    6080       110128 :   TYPE_USER_ALIGN (t) = 1;
    6081              : 
    6082       110128 :   return t;
    6083              : }
    6084              : 
    6085              : /* Create a new distinct copy of TYPE.  The new type is made its own
    6086              :    MAIN_VARIANT. If TYPE requires structural equality checks, the
    6087              :    resulting type requires structural equality checks; otherwise, its
    6088              :    TYPE_CANONICAL points to itself. */
    6089              : 
    6090              : tree
    6091    812892300 : build_distinct_type_copy (tree type MEM_STAT_DECL)
    6092              : {
    6093    812892300 :   tree t = copy_node (type PASS_MEM_STAT);
    6094              : 
    6095    812892300 :   TYPE_POINTER_TO (t) = 0;
    6096    812892300 :   TYPE_REFERENCE_TO (t) = 0;
    6097              : 
    6098              :   /* Set the canonical type either to a new equivalence class, or
    6099              :      propagate the need for structural equality checks. */
    6100    812892300 :   if (TYPE_STRUCTURAL_EQUALITY_P (type))
    6101     68458582 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    6102              :   else
    6103    744433718 :     TYPE_CANONICAL (t) = t;
    6104              : 
    6105              :   /* Make it its own variant.  */
    6106    812892300 :   TYPE_MAIN_VARIANT (t) = t;
    6107    812892300 :   TYPE_NEXT_VARIANT (t) = 0;
    6108              : 
    6109              :   /* Note that it is now possible for TYPE_MIN_VALUE to be a value
    6110              :      whose TREE_TYPE is not t.  This can also happen in the Ada
    6111              :      frontend when using subtypes.  */
    6112              : 
    6113    812892300 :   return t;
    6114              : }
    6115              : 
    6116              : /* Create a new variant of TYPE, equivalent but distinct.  This is so
    6117              :    the caller can modify it. TYPE_CANONICAL for the return type will
    6118              :    be equivalent to TYPE_CANONICAL of TYPE, indicating that the types
    6119              :    are considered equal by the language itself (or that both types
    6120              :    require structural equality checks). */
    6121              : 
    6122              : tree
    6123    521122969 : build_variant_type_copy (tree type MEM_STAT_DECL)
    6124              : {
    6125    521122969 :   tree t, m = TYPE_MAIN_VARIANT (type);
    6126              : 
    6127    521122969 :   t = build_distinct_type_copy (type PASS_MEM_STAT);
    6128              : 
    6129              :   /* Since we're building a variant, assume that it is a non-semantic
    6130              :      variant.  This also propagates TYPE_STRUCTURAL_EQUALITY_P. */
    6131    521122969 :   TYPE_CANONICAL (t) = TYPE_CANONICAL (type);
    6132              :   /* Type variants have no alias set defined.  */
    6133    521122969 :   TYPE_ALIAS_SET (t) = -1;
    6134              : 
    6135              :   /* Add the new type to the chain of variants of TYPE.  */
    6136    521122969 :   TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
    6137    521122969 :   TYPE_NEXT_VARIANT (m) = t;
    6138    521122969 :   TYPE_MAIN_VARIANT (t) = m;
    6139              : 
    6140    521122969 :   return t;
    6141              : }
    6142              : 
    6143              : /* Return true if the from tree in both tree maps are equal.  */
    6144              : 
    6145              : int
    6146   1973127348 : tree_map_base_eq (const void *va, const void *vb)
    6147              : {
    6148   1973127348 :   const struct tree_map_base  *const a = (const struct tree_map_base *) va,
    6149   1973127348 :     *const b = (const struct tree_map_base *) vb;
    6150   1973127348 :   return (a->from == b->from);
    6151              : }
    6152              : 
    6153              : /* Hash a from tree in a tree_base_map.  */
    6154              : 
    6155              : unsigned int
    6156            0 : tree_map_base_hash (const void *item)
    6157              : {
    6158            0 :   return htab_hash_pointer (((const struct tree_map_base *)item)->from);
    6159              : }
    6160              : 
    6161              : /* Return true if this tree map structure is marked for garbage collection
    6162              :    purposes.  We simply return true if the from tree is marked, so that this
    6163              :    structure goes away when the from tree goes away.  */
    6164              : 
    6165              : bool
    6166            0 : tree_map_base_marked_p (const void *p)
    6167              : {
    6168            0 :   return ggc_marked_p (((const struct tree_map_base *) p)->from);
    6169              : }
    6170              : 
    6171              : /* Hash a from tree in a tree_map.  */
    6172              : 
    6173              : unsigned int
    6174          193 : tree_map_hash (const void *item)
    6175              : {
    6176          193 :   return (((const struct tree_map *) item)->hash);
    6177              : }
    6178              : 
    6179              : /* Hash a from tree in a tree_decl_map.  */
    6180              : 
    6181              : unsigned int
    6182   1362009849 : tree_decl_map_hash (const void *item)
    6183              : {
    6184   1362009849 :   return DECL_UID (((const struct tree_decl_map *) item)->base.from);
    6185              : }
    6186              : 
    6187              : /* Return the initialization priority for DECL.  */
    6188              : 
    6189              : priority_type
    6190        23703 : decl_init_priority_lookup (tree decl)
    6191              : {
    6192        23703 :   symtab_node *snode = symtab_node::get (decl);
    6193              : 
    6194        23703 :   if (!snode)
    6195              :     return DEFAULT_INIT_PRIORITY;
    6196        23703 :   return
    6197        23703 :     snode->get_init_priority ();
    6198              : }
    6199              : 
    6200              : /* Return the finalization priority for DECL.  */
    6201              : 
    6202              : priority_type
    6203         1895 : decl_fini_priority_lookup (tree decl)
    6204              : {
    6205         1895 :   cgraph_node *node = cgraph_node::get (decl);
    6206              : 
    6207         1895 :   if (!node)
    6208              :     return DEFAULT_INIT_PRIORITY;
    6209         1895 :   return
    6210         1895 :     node->get_fini_priority ();
    6211              : }
    6212              : 
    6213              : /* Set the initialization priority for DECL to PRIORITY.  */
    6214              : 
    6215              : void
    6216        25252 : decl_init_priority_insert (tree decl, priority_type priority)
    6217              : {
    6218        25252 :   struct symtab_node *snode;
    6219              : 
    6220        25252 :   if (priority == DEFAULT_INIT_PRIORITY)
    6221              :     {
    6222        21697 :       snode = symtab_node::get (decl);
    6223        21697 :       if (!snode)
    6224              :         return;
    6225              :     }
    6226              :   else
    6227         3555 :     snode = symtab_node::get_create (decl);
    6228        24391 :   snode->set_init_priority (priority);
    6229              : }
    6230              : 
    6231              : /* Set the finalization priority for DECL to PRIORITY.  */
    6232              : 
    6233              : void
    6234         1755 : decl_fini_priority_insert (tree decl, priority_type priority)
    6235              : {
    6236         1755 :   struct cgraph_node *node;
    6237              : 
    6238         1755 :   if (priority == DEFAULT_INIT_PRIORITY)
    6239              :     {
    6240          105 :       node = cgraph_node::get (decl);
    6241          105 :       if (!node)
    6242              :         return;
    6243              :     }
    6244              :   else
    6245         1650 :     node = cgraph_node::get_create (decl);
    6246         1660 :   node->set_fini_priority (priority);
    6247              : }
    6248              : 
    6249              : /* Print out the statistics for the DECL_DEBUG_EXPR hash table.  */
    6250              : 
    6251              : static void
    6252            0 : print_debug_expr_statistics (void)
    6253              : {
    6254            0 :   fprintf (stderr, "DECL_DEBUG_EXPR  hash: size " HOST_SIZE_T_PRINT_DEC ", "
    6255              :            HOST_SIZE_T_PRINT_DEC " elements, %f collisions\n",
    6256            0 :            (fmt_size_t) debug_expr_for_decl->size (),
    6257            0 :            (fmt_size_t) debug_expr_for_decl->elements (),
    6258              :            debug_expr_for_decl->collisions ());
    6259            0 : }
    6260              : 
    6261              : /* Print out the statistics for the DECL_VALUE_EXPR hash table.  */
    6262              : 
    6263              : static void
    6264            0 : print_value_expr_statistics (void)
    6265              : {
    6266            0 :   fprintf (stderr, "DECL_VALUE_EXPR  hash: size " HOST_SIZE_T_PRINT_DEC ", "
    6267              :            HOST_SIZE_T_PRINT_DEC " elements, %f collisions\n",
    6268            0 :            (fmt_size_t) value_expr_for_decl->size (),
    6269            0 :            (fmt_size_t) value_expr_for_decl->elements (),
    6270              :            value_expr_for_decl->collisions ());
    6271            0 : }
    6272              : 
    6273              : /* Lookup a debug expression for FROM, and return it if we find one.  */
    6274              : 
    6275              : tree
    6276    450408554 : decl_debug_expr_lookup (tree from)
    6277              : {
    6278    450408554 :   struct tree_decl_map *h, in;
    6279    450408554 :   in.base.from = from;
    6280              : 
    6281    450408554 :   h = debug_expr_for_decl->find_with_hash (&in, DECL_UID (from));
    6282    450408554 :   if (h)
    6283    450408554 :     return h->to;
    6284              :   return NULL_TREE;
    6285              : }
    6286              : 
    6287              : /* Insert a mapping FROM->TO in the debug expression hashtable.  */
    6288              : 
    6289              : void
    6290      1434385 : decl_debug_expr_insert (tree from, tree to)
    6291              : {
    6292      1434385 :   struct tree_decl_map *h;
    6293              : 
    6294      1434385 :   h = ggc_alloc<tree_decl_map> ();
    6295      1434385 :   h->base.from = from;
    6296      1434385 :   h->to = to;
    6297      1434385 :   *debug_expr_for_decl->find_slot_with_hash (h, DECL_UID (from), INSERT) = h;
    6298      1434385 : }
    6299              : 
    6300              : /* Lookup a value expression for FROM, and return it if we find one.  */
    6301              : 
    6302              : tree
    6303     24357364 : decl_value_expr_lookup (tree from)
    6304              : {
    6305     24357364 :   struct tree_decl_map *h, in;
    6306     24357364 :   in.base.from = from;
    6307              : 
    6308     24357364 :   h = value_expr_for_decl->find_with_hash (&in, DECL_UID (from));
    6309     24357364 :   if (h)
    6310     24357364 :     return h->to;
    6311              :   return NULL_TREE;
    6312              : }
    6313              : 
    6314              : /* Insert a mapping FROM->TO in the value expression hashtable.  */
    6315              : 
    6316              : void
    6317      8954978 : decl_value_expr_insert (tree from, tree to)
    6318              : {
    6319      8954978 :   struct tree_decl_map *h;
    6320              : 
    6321              :   /* Uses of FROM shouldn't look like they happen at the location of TO.  */
    6322      8954978 :   to = protected_set_expr_location_unshare (to, UNKNOWN_LOCATION);
    6323              : 
    6324      8954978 :   h = ggc_alloc<tree_decl_map> ();
    6325      8954978 :   h->base.from = from;
    6326      8954978 :   h->to = to;
    6327      8954978 :   *value_expr_for_decl->find_slot_with_hash (h, DECL_UID (from), INSERT) = h;
    6328      8954978 : }
    6329              : 
    6330              : /* Lookup a vector of debug arguments for FROM, and return it if we
    6331              :    find one.  */
    6332              : 
    6333              : vec<tree, va_gc> **
    6334       953486 : decl_debug_args_lookup (tree from)
    6335              : {
    6336       953486 :   struct tree_vec_map *h, in;
    6337              : 
    6338       953486 :   if (!DECL_HAS_DEBUG_ARGS_P (from))
    6339              :     return NULL;
    6340       811779 :   gcc_checking_assert (debug_args_for_decl != NULL);
    6341       811779 :   in.base.from = from;
    6342       811779 :   h = debug_args_for_decl->find_with_hash (&in, DECL_UID (from));
    6343       811779 :   if (h)
    6344       807893 :     return &h->to;
    6345              :   return NULL;
    6346              : }
    6347              : 
    6348              : /* Insert a mapping FROM->empty vector of debug arguments in the value
    6349              :    expression hashtable.  */
    6350              : 
    6351              : vec<tree, va_gc> **
    6352       301237 : decl_debug_args_insert (tree from)
    6353              : {
    6354       301237 :   struct tree_vec_map *h;
    6355       301237 :   tree_vec_map **loc;
    6356              : 
    6357       301237 :   if (DECL_HAS_DEBUG_ARGS_P (from))
    6358       210247 :     return decl_debug_args_lookup (from);
    6359        90990 :   if (debug_args_for_decl == NULL)
    6360         8273 :     debug_args_for_decl = hash_table<tree_vec_map_cache_hasher>::create_ggc (64);
    6361        90990 :   h = ggc_alloc<tree_vec_map> ();
    6362        90990 :   h->base.from = from;
    6363        90990 :   h->to = NULL;
    6364        90990 :   loc = debug_args_for_decl->find_slot_with_hash (h, DECL_UID (from), INSERT);
    6365        90990 :   *loc = h;
    6366        90990 :   DECL_HAS_DEBUG_ARGS_P (from) = 1;
    6367        90990 :   return &h->to;
    6368              : }
    6369              : 
    6370              : /* Hashing of types so that we don't make duplicates.
    6371              :    The entry point is `type_hash_canon'.  */
    6372              : 
    6373              : /* Generate the default hash code for TYPE.  This is designed for
    6374              :    speed, rather than maximum entropy.  */
    6375              : 
    6376              : hashval_t
    6377   1471928171 : type_hash_canon_hash (tree type)
    6378              : {
    6379   1471928171 :   inchash::hash hstate;
    6380              : 
    6381   1471928171 :   hstate.add_int (TREE_CODE (type));
    6382              : 
    6383   1471928171 :   hstate.add_flag (TYPE_STRUCTURAL_EQUALITY_P (type));
    6384              : 
    6385   1471928171 :   if (TREE_TYPE (type))
    6386   1471843514 :     hstate.add_object (TYPE_HASH (TREE_TYPE (type)));
    6387              : 
    6388   1759212698 :   for (tree t = TYPE_ATTRIBUTES (type); t; t = TREE_CHAIN (t))
    6389              :     /* Just the identifier is adequate to distinguish.  */
    6390    287284527 :     hstate.add_object (IDENTIFIER_HASH_VALUE (get_attribute_name (t)));
    6391              : 
    6392   1471928171 :   switch (TREE_CODE (type))
    6393              :     {
    6394    343020167 :     case METHOD_TYPE:
    6395    343020167 :       hstate.add_object (TYPE_HASH (TYPE_METHOD_BASETYPE (type)));
    6396              :       /* FALLTHROUGH. */
    6397   1274866981 :     case FUNCTION_TYPE:
    6398   5028678227 :       for (tree t = TYPE_ARG_TYPES (type); t; t = TREE_CHAIN (t))
    6399   3753811246 :         if (TREE_VALUE (t) != error_mark_node)
    6400   3753767767 :           hstate.add_object (TYPE_HASH (TREE_VALUE (t)));
    6401              :       break;
    6402              : 
    6403       984103 :     case OFFSET_TYPE:
    6404       984103 :       hstate.add_object (TYPE_HASH (TYPE_OFFSET_BASETYPE (type)));
    6405       984103 :       break;
    6406              : 
    6407     73923545 :     case ARRAY_TYPE:
    6408     73923545 :       {
    6409     73923545 :         if (TYPE_DOMAIN (type))
    6410     70907094 :           hstate.add_object (TYPE_HASH (TYPE_DOMAIN (type)));
    6411     73923545 :         if (!AGGREGATE_TYPE_P (TREE_TYPE (type)))
    6412              :           {
    6413     71419499 :             unsigned typeless = TYPE_TYPELESS_STORAGE (type);
    6414     71419499 :             hstate.add_object (typeless);
    6415              :           }
    6416              :       }
    6417              :       break;
    6418              : 
    6419     43898056 :     case INTEGER_TYPE:
    6420     43898056 :       {
    6421     43898056 :         tree t = TYPE_MAX_VALUE (type);
    6422     43898056 :         if (!t)
    6423       560720 :           t = TYPE_MIN_VALUE (type);
    6424     87796113 :         for (int i = 0; i < TREE_INT_CST_NUNITS (t); i++)
    6425     43898057 :           hstate.add_object (TREE_INT_CST_ELT (t, i));
    6426              :         break;
    6427              :       }
    6428              : 
    6429        62142 :     case BITINT_TYPE:
    6430        62142 :       {
    6431        62142 :         unsigned prec = TYPE_PRECISION (type);
    6432        62142 :         unsigned uns = TYPE_UNSIGNED (type);
    6433        62142 :         hstate.add_object (prec);
    6434        62142 :         hstate.add_int (uns);
    6435        62142 :         break;
    6436              :       }
    6437              : 
    6438        12128 :     case REAL_TYPE:
    6439        12128 :     case FIXED_POINT_TYPE:
    6440        12128 :       {
    6441        12128 :         unsigned prec = TYPE_PRECISION (type);
    6442        12128 :         hstate.add_object (prec);
    6443        12128 :         break;
    6444              :       }
    6445              : 
    6446     72391214 :     case VECTOR_TYPE:
    6447     72391214 :       hstate.add_poly_int (TYPE_VECTOR_SUBPARTS (type));
    6448     72391214 :       break;
    6449              : 
    6450              :     case REFERENCE_TYPE:
    6451   1471928171 :       hstate.add_flag (TYPE_REF_IS_RVALUE (type));
    6452              :       break;
    6453              : 
    6454              :     default:
    6455              :       break;
    6456              :     }
    6457              : 
    6458   1471928171 :   return hstate.end ();
    6459              : }
    6460              : 
    6461              : /* These are the Hashtable callback functions.  */
    6462              : 
    6463              : /* Returns true iff the types are equivalent.  */
    6464              : 
    6465              : bool
    6466   9938341241 : type_cache_hasher::equal (type_hash *a, type_hash *b)
    6467              : {
    6468              :   /* First test the things that are the same for all types.  */
    6469   9938341241 :   if (a->hash != b->hash
    6470    721132179 :       || TREE_CODE (a->type) != TREE_CODE (b->type)
    6471    721131864 :       || TREE_TYPE (a->type) != TREE_TYPE (b->type)
    6472    721131505 :       || !attribute_list_equal (TYPE_ATTRIBUTES (a->type),
    6473    721131505 :                                  TYPE_ATTRIBUTES (b->type))
    6474  10652203907 :       || (TREE_CODE (a->type) != COMPLEX_TYPE
    6475    711599765 :           && TYPE_NAME (a->type) != TYPE_NAME (b->type)))
    6476              :     return false;
    6477              : 
    6478              :   /* Be careful about comparing arrays before and after the element type
    6479              :      has been completed; don't compare TYPE_ALIGN unless both types are
    6480              :      complete.  */
    6481   1422679613 :   if (COMPLETE_TYPE_P (a->type) && COMPLETE_TYPE_P (b->type)
    6482   1422679613 :       && (TYPE_ALIGN (a->type) != TYPE_ALIGN (b->type)
    6483    709724513 :           || TYPE_MODE (a->type) != TYPE_MODE (b->type)))
    6484              :     return false;
    6485              : 
    6486    712953954 :   if (TYPE_STRUCTURAL_EQUALITY_P (a->type)
    6487    712953954 :       != TYPE_STRUCTURAL_EQUALITY_P (b->type))
    6488              :     return false;
    6489              : 
    6490    712943729 :   switch (TREE_CODE (a->type))
    6491              :     {
    6492              :     case VOID_TYPE:
    6493              :     case OPAQUE_TYPE:
    6494              :     case COMPLEX_TYPE:
    6495              :     case POINTER_TYPE:
    6496              :     case NULLPTR_TYPE:
    6497              :       return true;
    6498              : 
    6499     65629902 :     case VECTOR_TYPE:
    6500     65629902 :       return known_eq (TYPE_VECTOR_SUBPARTS (a->type),
    6501              :                        TYPE_VECTOR_SUBPARTS (b->type));
    6502              : 
    6503            0 :     case ENUMERAL_TYPE:
    6504            0 :       if (TYPE_VALUES (a->type) != TYPE_VALUES (b->type)
    6505            0 :           && !(TYPE_VALUES (a->type)
    6506            0 :                && TREE_CODE (TYPE_VALUES (a->type)) == TREE_LIST
    6507            0 :                && TYPE_VALUES (b->type)
    6508            0 :                && TREE_CODE (TYPE_VALUES (b->type)) == TREE_LIST
    6509            0 :                && type_list_equal (TYPE_VALUES (a->type),
    6510            0 :                                    TYPE_VALUES (b->type))))
    6511              :         return false;
    6512              : 
    6513              :       /* fall through */
    6514              : 
    6515     40924295 :     case INTEGER_TYPE:
    6516     40924295 :     case REAL_TYPE:
    6517     40924295 :     case BOOLEAN_TYPE:
    6518     40924295 :       if (TYPE_PRECISION (a->type) != TYPE_PRECISION (b->type))
    6519              :         return false;
    6520     40910415 :       return ((TYPE_MAX_VALUE (a->type) == TYPE_MAX_VALUE (b->type)
    6521       777504 :                || tree_int_cst_equal (TYPE_MAX_VALUE (a->type),
    6522       777504 :                                       TYPE_MAX_VALUE (b->type)))
    6523     41273736 :               && (TYPE_MIN_VALUE (a->type) == TYPE_MIN_VALUE (b->type)
    6524       520015 :                   || tree_int_cst_equal (TYPE_MIN_VALUE (a->type),
    6525       520015 :                                          TYPE_MIN_VALUE (b->type))));
    6526              : 
    6527        55020 :     case BITINT_TYPE:
    6528        55020 :       if (TYPE_PRECISION (a->type) != TYPE_PRECISION (b->type))
    6529              :         return false;
    6530        55020 :       return TYPE_UNSIGNED (a->type) == TYPE_UNSIGNED (b->type);
    6531              : 
    6532            0 :     case FIXED_POINT_TYPE:
    6533            0 :       return TYPE_SATURATING (a->type) == TYPE_SATURATING (b->type);
    6534              : 
    6535       746660 :     case OFFSET_TYPE:
    6536       746660 :       return TYPE_OFFSET_BASETYPE (a->type) == TYPE_OFFSET_BASETYPE (b->type);
    6537              : 
    6538     95195880 :     case METHOD_TYPE:
    6539     95195880 :       if (TYPE_METHOD_BASETYPE (a->type) == TYPE_METHOD_BASETYPE (b->type)
    6540     95195880 :           && (TYPE_ARG_TYPES (a->type) == TYPE_ARG_TYPES (b->type)
    6541     95046909 :               || (TYPE_ARG_TYPES (a->type)
    6542     95046909 :                   && TREE_CODE (TYPE_ARG_TYPES (a->type)) == TREE_LIST
    6543     95046909 :                   && TYPE_ARG_TYPES (b->type)
    6544     95046909 :                   && TREE_CODE (TYPE_ARG_TYPES (b->type)) == TREE_LIST
    6545     95046909 :                   && type_list_equal (TYPE_ARG_TYPES (a->type),
    6546     95046909 :                                       TYPE_ARG_TYPES (b->type)))))
    6547              :         break;
    6548              :       return false;
    6549     62551019 :     case ARRAY_TYPE:
    6550              :       /* Don't compare TYPE_TYPELESS_STORAGE flag on aggregates,
    6551              :          where the flag should be inherited from the element type
    6552              :          and can change after ARRAY_TYPEs are created; on non-aggregates
    6553              :          compare it and hash it, scalars will never have that flag set
    6554              :          and we need to differentiate between arrays created by different
    6555              :          front-ends or middle-end created arrays.  */
    6556     62551019 :       return (TYPE_DOMAIN (a->type) == TYPE_DOMAIN (b->type)
    6557     62551019 :               && (AGGREGATE_TYPE_P (TREE_TYPE (a->type))
    6558     60696604 :                   || (TYPE_TYPELESS_STORAGE (a->type)
    6559     60696604 :                       == TYPE_TYPELESS_STORAGE (b->type))));
    6560              : 
    6561            0 :     case RECORD_TYPE:
    6562            0 :     case UNION_TYPE:
    6563            0 :     case QUAL_UNION_TYPE:
    6564            0 :       return (TYPE_FIELDS (a->type) == TYPE_FIELDS (b->type)
    6565            0 :               || (TYPE_FIELDS (a->type)
    6566            0 :                   && TREE_CODE (TYPE_FIELDS (a->type)) == TREE_LIST
    6567            0 :                   && TYPE_FIELDS (b->type)
    6568            0 :                   && TREE_CODE (TYPE_FIELDS (b->type)) == TREE_LIST
    6569            0 :                   && type_list_equal (TYPE_FIELDS (a->type),
    6570            0 :                                       TYPE_FIELDS (b->type))));
    6571              : 
    6572    445577594 :     case FUNCTION_TYPE:
    6573    445577594 :       if ((TYPE_ARG_TYPES (a->type) == TYPE_ARG_TYPES (b->type)
    6574    282174661 :            && (TYPE_NO_NAMED_ARGS_STDARG_P (a->type)
    6575    282174661 :                == TYPE_NO_NAMED_ARGS_STDARG_P (b->type)))
    6576    446030684 :           || (TYPE_ARG_TYPES (a->type)
    6577    163402933 :               && TREE_CODE (TYPE_ARG_TYPES (a->type)) == TREE_LIST
    6578    163402933 :               && TYPE_ARG_TYPES (b->type)
    6579    163402918 :               && TREE_CODE (TYPE_ARG_TYPES (b->type)) == TREE_LIST
    6580    163402918 :               && type_list_equal (TYPE_ARG_TYPES (a->type),
    6581    163402918 :                                   TYPE_ARG_TYPES (b->type))))
    6582              :         break;
    6583              :       return false;
    6584              : 
    6585            9 :     case REFERENCE_TYPE:
    6586            9 :       return TYPE_REF_IS_RVALUE (a->type) == TYPE_REF_IS_RVALUE (b->type);
    6587              : 
    6588              :     default:
    6589              :       return false;
    6590              :     }
    6591              : 
    6592    512626511 :   if (lang_hooks.types.type_hash_eq != NULL)
    6593    324075884 :     return lang_hooks.types.type_hash_eq (a->type, b->type);
    6594              : 
    6595              :   return true;
    6596              : }
    6597              : 
    6598              : /* Given TYPE, and HASHCODE its hash code, return the canonical
    6599              :    object for an identical type if one already exists.
    6600              :    Otherwise, return TYPE, and record it as the canonical object.
    6601              : 
    6602              :    To use this function, first create a type of the sort you want.
    6603              :    Then compute its hash code from the fields of the type that
    6604              :    make it different from other similar types.
    6605              :    Then call this function and use the value.  */
    6606              : 
    6607              : tree
    6608   1473060549 : type_hash_canon (unsigned int hashcode, tree type)
    6609              : {
    6610   1473060549 :   type_hash in;
    6611   1473060549 :   type_hash **loc;
    6612              : 
    6613              :   /* The hash table only contains main variants, so ensure that's what we're
    6614              :      being passed.  */
    6615   1473060549 :   gcc_assert (TYPE_MAIN_VARIANT (type) == type);
    6616              : 
    6617              :   /* The TYPE_ALIGN field of a type is set by layout_type(), so we
    6618              :      must call that routine before comparing TYPE_ALIGNs.  */
    6619   1473060549 :   layout_type (type);
    6620              : 
    6621   1473060549 :   in.hash = hashcode;
    6622   1473060549 :   in.type = type;
    6623              : 
    6624   1473060549 :   loc = type_hash_table->find_slot_with_hash (&in, hashcode, INSERT);
    6625   1473060549 :   if (*loc)
    6626              :     {
    6627    684205651 :       tree t1 = ((type_hash *) *loc)->type;
    6628    684205651 :       gcc_assert (TYPE_MAIN_VARIANT (t1) == t1
    6629              :                   && t1 != type);
    6630    684205651 :       if (TYPE_UID (type) + 1 == next_type_uid)
    6631    678634480 :         --next_type_uid;
    6632              :       /* Free also min/max values and the cache for integer
    6633              :          types.  This can't be done in free_node, as LTO frees
    6634              :          those on its own.  */
    6635    684205651 :       if (TREE_CODE (type) == INTEGER_TYPE || TREE_CODE (type) == BITINT_TYPE)
    6636              :         {
    6637     40388197 :           if (TYPE_MIN_VALUE (type)
    6638     40388197 :               && TREE_TYPE (TYPE_MIN_VALUE (type)) == type)
    6639              :             {
    6640              :               /* Zero is always in TYPE_CACHED_VALUES.  */
    6641       411328 :               if (! TYPE_UNSIGNED (type))
    6642       232074 :                 int_cst_hash_table->remove_elt (TYPE_MIN_VALUE (type));
    6643       411328 :               ggc_free (TYPE_MIN_VALUE (type));
    6644              :             }
    6645     40388197 :           if (TYPE_MAX_VALUE (type)
    6646     40388197 :               && TREE_TYPE (TYPE_MAX_VALUE (type)) == type)
    6647              :             {
    6648       411328 :               int_cst_hash_table->remove_elt (TYPE_MAX_VALUE (type));
    6649       411328 :               ggc_free (TYPE_MAX_VALUE (type));
    6650              :             }
    6651     40388197 :           if (TYPE_CACHED_VALUES_P (type))
    6652       179254 :             ggc_free (TYPE_CACHED_VALUES (type));
    6653              :         }
    6654    684205651 :       free_node (type);
    6655    684205651 :       return t1;
    6656              :     }
    6657              :   else
    6658              :     {
    6659    788854898 :       struct type_hash *h;
    6660              : 
    6661    788854898 :       h = ggc_alloc<type_hash> ();
    6662    788854898 :       h->hash = hashcode;
    6663    788854898 :       h->type = type;
    6664    788854898 :       *loc = h;
    6665              : 
    6666    788854898 :       return type;
    6667              :     }
    6668              : }
    6669              : 
    6670              : static void
    6671            0 : print_type_hash_statistics (void)
    6672              : {
    6673            0 :   fprintf (stderr, "Type hash: size " HOST_SIZE_T_PRINT_DEC ", "
    6674              :            HOST_SIZE_T_PRINT_DEC " elements, %f collisions\n",
    6675            0 :            (fmt_size_t) type_hash_table->size (),
    6676            0 :            (fmt_size_t) type_hash_table->elements (),
    6677              :            type_hash_table->collisions ());
    6678            0 : }
    6679              : 
    6680              : /* Given two lists of types
    6681              :    (chains of TREE_LIST nodes with types in the TREE_VALUE slots)
    6682              :    return 1 if the lists contain the same types in the same order.
    6683              :    Also, the TREE_PURPOSEs must match.  */
    6684              : 
    6685              : bool
    6686    258450363 : type_list_equal (const_tree l1, const_tree l2)
    6687              : {
    6688    258450363 :   const_tree t1, t2;
    6689              : 
    6690    971838648 :   for (t1 = l1, t2 = l2; t1 && t2; t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2))
    6691    741081910 :     if (TREE_VALUE (t1) != TREE_VALUE (t2)
    6692    741081910 :         || (TREE_PURPOSE (t1) != TREE_PURPOSE (t2)
    6693     27695698 :             && ! (1 == simple_cst_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2))
    6694         2109 :                   && (TREE_TYPE (TREE_PURPOSE (t1))
    6695         2109 :                       == TREE_TYPE (TREE_PURPOSE (t2))))))
    6696              :       return false;
    6697              : 
    6698    230756738 :   return t1 == t2;
    6699              : }
    6700              : 
    6701              : /* Returns the number of arguments to the FUNCTION_TYPE or METHOD_TYPE
    6702              :    given by TYPE.  If the argument list accepts variable arguments,
    6703              :    then this function counts only the ordinary arguments.  */
    6704              : 
    6705              : int
    6706     82296471 : type_num_arguments (const_tree fntype)
    6707              : {
    6708     82296471 :   int i = 0;
    6709              : 
    6710    320449056 :   for (tree t = TYPE_ARG_TYPES (fntype); t; t = TREE_CHAIN (t))
    6711              :     /* If the function does not take a variable number of arguments,
    6712              :        the last element in the list will have type `void'.  */
    6713    301178572 :     if (VOID_TYPE_P (TREE_VALUE (t)))
    6714              :       break;
    6715              :     else
    6716    238152585 :       ++i;
    6717              : 
    6718     82296471 :   return i;
    6719              : }
    6720              : 
    6721              : /* Return the type of the function TYPE's argument ARGNO if known.
    6722              :    For vararg function's where ARGNO refers to one of the variadic
    6723              :    arguments return null.  Otherwise, return a void_type_node for
    6724              :    out-of-bounds ARGNO.  */
    6725              : 
    6726              : tree
    6727     81235260 : type_argument_type (const_tree fntype, unsigned argno)
    6728              : {
    6729              :   /* Treat zero the same as an out-of-bounds argument number.  */
    6730     81235260 :   if (!argno)
    6731            0 :     return void_type_node;
    6732              : 
    6733     81235260 :   function_args_iterator iter;
    6734              : 
    6735     81235260 :   tree argtype;
    6736     81235260 :   unsigned i = 1;
    6737    174951894 :   FOREACH_FUNCTION_ARGS (fntype, argtype, iter)
    6738              :     {
    6739              :       /* A vararg function's argument list ends in a null.  Otherwise,
    6740              :          an ordinary function's argument list ends with void.  Return
    6741              :          null if ARGNO refers to a vararg argument, void_type_node if
    6742              :          it's out of bounds, and the formal argument type otherwise.  */
    6743    169169424 :       if (!argtype)
    6744              :         break;
    6745              : 
    6746    169169424 :       if (i == argno || VOID_TYPE_P (argtype))
    6747              :         return argtype;
    6748              : 
    6749     93716634 :       ++i;
    6750              :     }
    6751              : 
    6752              :   return NULL_TREE;
    6753              : }
    6754              : 
    6755              : /* True if integer constants T1 and T2
    6756              :    represent the same constant value.  */
    6757              : 
    6758              : bool
    6759   1338224332 : tree_int_cst_equal (const_tree t1, const_tree t2)
    6760              : {
    6761   1338224332 :   if (t1 == t2)
    6762              :     return true;
    6763              : 
    6764    680003185 :   if (t1 == 0 || t2 == 0)
    6765              :     return false;
    6766              : 
    6767    679587506 :   STRIP_ANY_LOCATION_WRAPPER (t1);
    6768    679587506 :   STRIP_ANY_LOCATION_WRAPPER (t2);
    6769              : 
    6770    679587506 :   if (TREE_CODE (t1) == INTEGER_CST
    6771    675449714 :       && TREE_CODE (t2) == INTEGER_CST
    6772   1355037220 :       && wi::to_widest (t1) == wi::to_widest (t2))
    6773     20788386 :     return true;
    6774              : 
    6775              :   return false;
    6776              : }
    6777              : 
    6778              : /* Return true if T is an INTEGER_CST whose numerical value (extended
    6779              :    according to TYPE_UNSIGNED) fits in a signed HOST_WIDE_INT.  */
    6780              : 
    6781              : bool
    6782   2395025208 : tree_fits_shwi_p (const_tree t)
    6783              : {
    6784   2395025208 :   return (t != NULL_TREE
    6785   2395025117 :           && TREE_CODE (t) == INTEGER_CST
    6786   4787313395 :           && wi::fits_shwi_p (wi::to_widest (t)));
    6787              : }
    6788              : 
    6789              : /* Return true if T is an INTEGER_CST or POLY_INT_CST whose numerical
    6790              :    value (extended according to TYPE_UNSIGNED) fits in a poly_int64.  */
    6791              : 
    6792              : bool
    6793   1017585414 : tree_fits_poly_int64_p (const_tree t)
    6794              : {
    6795   1017585414 :   if (t == NULL_TREE)
    6796              :     return false;
    6797    979652715 :   if (POLY_INT_CST_P (t))
    6798              :     {
    6799              :       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; i++)
    6800              :         if (!wi::fits_shwi_p (wi::to_wide (POLY_INT_CST_COEFF (t, i))))
    6801              :           return false;
    6802              :       return true;
    6803              :     }
    6804    979652715 :   return (TREE_CODE (t) == INTEGER_CST
    6805   1959411176 :           && wi::fits_shwi_p (wi::to_widest (t)));
    6806              : }
    6807              : 
    6808              : /* Return true if T is an INTEGER_CST whose numerical value (extended
    6809              :    according to TYPE_UNSIGNED) fits in an unsigned HOST_WIDE_INT.  */
    6810              : 
    6811              : bool
    6812   4185573866 : tree_fits_uhwi_p (const_tree t)
    6813              : {
    6814   4185573866 :   return (t != NULL_TREE
    6815   4184936758 :           && TREE_CODE (t) == INTEGER_CST
    6816   8365068818 :           && wi::fits_uhwi_p (wi::to_widest (t)));
    6817              : }
    6818              : 
    6819              : /* Return true if T is an INTEGER_CST or POLY_INT_CST whose numerical
    6820              :    value (extended according to TYPE_UNSIGNED) fits in a poly_uint64.  */
    6821              : 
    6822              : bool
    6823   1085423378 : tree_fits_poly_uint64_p (const_tree t)
    6824              : {
    6825   1085423378 :   if (t == NULL_TREE)
    6826              :     return false;
    6827   1085062641 :   if (POLY_INT_CST_P (t))
    6828              :     {
    6829              :       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; i++)
    6830              :         if (!wi::fits_uhwi_p (wi::to_widest (POLY_INT_CST_COEFF (t, i))))
    6831              :           return false;
    6832              :       return true;
    6833              :     }
    6834   1085062641 :   return (TREE_CODE (t) == INTEGER_CST
    6835   2170126697 :           && wi::fits_uhwi_p (wi::to_widest (t)));
    6836              : }
    6837              : 
    6838              : /* Return true if T is an INTEGER_CST whose numerical value (extended according
    6839              :    to TYPE_UNSIGNED) fits in a sanitize_code_type (uint64_t).  */
    6840              : 
    6841              : bool
    6842           90 : tree_fits_sanitize_code_type_p (const_tree t)
    6843              : {
    6844           90 :   if (t == NULL_TREE)
    6845              :     return false;
    6846           90 :   return (TREE_CODE (t) == INTEGER_CST
    6847          180 :           && wi::fits_uhwi_p (wi::to_widest (t)));
    6848              : }
    6849              : 
    6850              : /* T is an INTEGER_CST whose numerical value (extended according to
    6851              :    TYPE_UNSIGNED) fits in a signed HOST_WIDE_INT.  Return that
    6852              :    HOST_WIDE_INT.  */
    6853              : 
    6854              : HOST_WIDE_INT
    6855   1416818204 : tree_to_shwi (const_tree t)
    6856              : {
    6857   1416818204 :   gcc_assert (tree_fits_shwi_p (t));
    6858   1416818204 :   return TREE_INT_CST_LOW (t);
    6859              : }
    6860              : 
    6861              : /* T is an INTEGER_CST whose numerical value (extended according to
    6862              :    TYPE_UNSIGNED) fits in an unsigned HOST_WIDE_INT.  Return that
    6863              :    HOST_WIDE_INT.  */
    6864              : 
    6865              : unsigned HOST_WIDE_INT
    6866   1040866920 : tree_to_uhwi (const_tree t)
    6867              : {
    6868   1040866920 :   gcc_assert (tree_fits_uhwi_p (t));
    6869   1040866920 :   return TREE_INT_CST_LOW (t);
    6870              : }
    6871              : 
    6872              : /* T is an INTEGER_CST whose numerical value (extended according to
    6873              :    TYPE_UNSIGNED) fits in a sanitize_code_type.  Return that
    6874              :    sanitize_code_type.  */
    6875              : 
    6876              : sanitize_code_type
    6877           90 : tree_to_sanitize_code_type (const_tree t)
    6878              : {
    6879           90 :   gcc_assert (tree_fits_sanitize_code_type_p (t));
    6880           90 :   return TREE_INT_CST_LOW (t);
    6881              : }
    6882              : 
    6883              : /* Return the most significant (sign) bit of T.  */
    6884              : 
    6885              : int
    6886     46357914 : tree_int_cst_sign_bit (const_tree t)
    6887              : {
    6888     46357914 :   unsigned bitno = TYPE_PRECISION (TREE_TYPE (t)) - 1;
    6889              : 
    6890     46357914 :   return wi::extract_uhwi (wi::to_wide (t), bitno, 1);
    6891              : }
    6892              : 
    6893              : /* Return an indication of the sign of the integer constant T.
    6894              :    The return value is -1 if T < 0, 0 if T == 0, and 1 if T > 0.
    6895              :    Note that -1 will never be returned if T's type is unsigned.  */
    6896              : 
    6897              : int
    6898   1900766401 : tree_int_cst_sgn (const_tree t)
    6899              : {
    6900   1900766401 :   if (wi::to_wide (t) == 0)
    6901              :     return 0;
    6902   1766992327 :   else if (TYPE_UNSIGNED (TREE_TYPE (t)))
    6903              :     return 1;
    6904     84547103 :   else if (wi::neg_p (wi::to_wide (t)))
    6905              :     return -1;
    6906              :   else
    6907     80852537 :     return 1;
    6908              : }
    6909              : 
    6910              : /* Return the minimum number of bits needed to represent VALUE in a
    6911              :    signed or unsigned type, UNSIGNEDP says which.  */
    6912              : 
    6913              : unsigned int
    6914      3693882 : tree_int_cst_min_precision (tree value, signop sgn)
    6915              : {
    6916              :   /* If the value is negative, compute its negative minus 1.  The latter
    6917              :      adjustment is because the absolute value of the largest negative value
    6918              :      is one larger than the largest positive value.  This is equivalent to
    6919              :      a bit-wise negation, so use that operation instead.  */
    6920              : 
    6921      3693882 :   if (tree_int_cst_sgn (value) < 0)
    6922       105248 :     value = fold_build1 (BIT_NOT_EXPR, TREE_TYPE (value), value);
    6923              : 
    6924              :   /* Return the number of bits needed, taking into account the fact
    6925              :      that we need one more bit for a signed than unsigned type.
    6926              :      If value is 0 or -1, the minimum precision is 1 no matter
    6927              :      whether unsignedp is true or false.  */
    6928              : 
    6929      3693882 :   if (integer_zerop (value))
    6930              :     return 1;
    6931              :   else
    6932      5271867 :     return tree_floor_log2 (value) + 1 + (sgn == SIGNED ? 1 : 0) ;
    6933              : }
    6934              : 
    6935              : /* Return truthvalue of whether T1 is the same tree structure as T2.
    6936              :    Return 1 if they are the same.
    6937              :    Return 0 if they are understandably different.
    6938              :    Return -1 if either contains tree structure not understood by
    6939              :    this function.  */
    6940              : 
    6941              : int
    6942    206863606 : simple_cst_equal (const_tree t1, const_tree t2)
    6943              : {
    6944    210549617 :   enum tree_code code1, code2;
    6945    210549617 :   int cmp;
    6946    210549617 :   int i;
    6947              : 
    6948    210549617 :   if (t1 == t2)
    6949              :     return 1;
    6950    134955168 :   if (t1 == 0 || t2 == 0)
    6951              :     return 0;
    6952              : 
    6953              :   /* For location wrappers to be the same, they must be at the same
    6954              :      source location (and wrap the same thing).  */
    6955    126070452 :   if (location_wrapper_p (t1) && location_wrapper_p (t2))
    6956              :     {
    6957     13194575 :       if (EXPR_LOCATION (t1) != EXPR_LOCATION (t2))
    6958              :         return 0;
    6959          962 :       return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    6960              :     }
    6961              : 
    6962    112875877 :   code1 = TREE_CODE (t1);
    6963    112875877 :   code2 = TREE_CODE (t2);
    6964              : 
    6965    112875877 :   if (CONVERT_EXPR_CODE_P (code1) || code1 == NON_LVALUE_EXPR)
    6966              :     {
    6967      3673116 :       if (CONVERT_EXPR_CODE_P (code2)
    6968      3672420 :           || code2 == NON_LVALUE_EXPR)
    6969          696 :         return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    6970              :       else
    6971      3672420 :         return simple_cst_equal (TREE_OPERAND (t1, 0), t2);
    6972              :     }
    6973              : 
    6974    109202761 :   else if (CONVERT_EXPR_CODE_P (code2)
    6975    109202746 :            || code2 == NON_LVALUE_EXPR)
    6976          113 :     return simple_cst_equal (t1, TREE_OPERAND (t2, 0));
    6977              : 
    6978    109202648 :   if (code1 != code2)
    6979              :     return 0;
    6980              : 
    6981    104820421 :   switch (code1)
    6982              :     {
    6983     95002716 :     case INTEGER_CST:
    6984     95002716 :       return wi::to_widest (t1) == wi::to_widest (t2);
    6985              : 
    6986           99 :     case REAL_CST:
    6987           99 :       return real_identical (&TREE_REAL_CST (t1), &TREE_REAL_CST (t2));
    6988              : 
    6989            0 :     case FIXED_CST:
    6990            0 :       return FIXED_VALUES_IDENTICAL (TREE_FIXED_CST (t1), TREE_FIXED_CST (t2));
    6991              : 
    6992      3282946 :     case STRING_CST:
    6993      3282946 :       return (TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
    6994      3282946 :               && ! memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
    6995      3769173 :                          TREE_STRING_LENGTH (t1)));
    6996              : 
    6997          477 :     case CONSTRUCTOR:
    6998          477 :       {
    6999          477 :         unsigned HOST_WIDE_INT idx;
    7000          477 :         vec<constructor_elt, va_gc> *v1 = CONSTRUCTOR_ELTS (t1);
    7001          477 :         vec<constructor_elt, va_gc> *v2 = CONSTRUCTOR_ELTS (t2);
    7002              : 
    7003          501 :         if (vec_safe_length (v1) != vec_safe_length (v2))
    7004              :           return 0;
    7005              : 
    7006          483 :         for (idx = 0; idx < vec_safe_length (v1); ++idx)
    7007              :           {
    7008           12 :             if ((*v1)[idx].index
    7009           12 :                 && TREE_CODE ((*v1)[idx].index) == FIELD_DECL)
    7010              :               {
    7011            9 :                 if ((*v1)[idx].index != (*v2)[idx].index)
    7012              :                   return 0;
    7013              :               }
    7014              :             else
    7015              :               {
    7016            3 :                 cmp = simple_cst_equal ((*v1)[idx].index, (*v2)[idx].index);
    7017            3 :                 if (cmp <= 0)
    7018              :                   return cmp;
    7019              :               }
    7020           12 :             cmp = simple_cst_equal ((*v1)[idx].value, (*v2)[idx].value);
    7021           12 :             if (cmp <= 0)
    7022              :               return cmp;
    7023              :           }
    7024              :         return 1;
    7025              :       }
    7026              : 
    7027            0 :     case SAVE_EXPR:
    7028            0 :       return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    7029              : 
    7030       203826 :     case CALL_EXPR:
    7031       203826 :       cmp = simple_cst_equal (CALL_EXPR_FN (t1), CALL_EXPR_FN (t2));
    7032       203826 :       if (cmp <= 0)
    7033              :         return cmp;
    7034        83887 :       if (call_expr_nargs (t1) != call_expr_nargs (t2))
    7035              :         return 0;
    7036        83887 :       {
    7037        83887 :         const_tree arg1, arg2;
    7038        83887 :         const_call_expr_arg_iterator iter1, iter2;
    7039       167774 :         for (arg1 = first_const_call_expr_arg (t1, &iter1),
    7040        83887 :                arg2 = first_const_call_expr_arg (t2, &iter2);
    7041        83918 :              arg1 && arg2;
    7042           31 :              arg1 = next_const_call_expr_arg (&iter1),
    7043           31 :                arg2 = next_const_call_expr_arg (&iter2))
    7044              :           {
    7045        83861 :             cmp = simple_cst_equal (arg1, arg2);
    7046        83861 :             if (cmp <= 0)
    7047              :               return cmp;
    7048              :           }
    7049           57 :         return arg1 == arg2;
    7050              :       }
    7051              : 
    7052        11591 :     case TARGET_EXPR:
    7053              :       /* Special case: if either target is an unallocated VAR_DECL,
    7054              :          it means that it's going to be unified with whatever the
    7055              :          TARGET_EXPR is really supposed to initialize, so treat it
    7056              :          as being equivalent to anything.  */
    7057        11591 :       if ((TREE_CODE (TREE_OPERAND (t1, 0)) == VAR_DECL
    7058        11591 :            && DECL_NAME (TREE_OPERAND (t1, 0)) == NULL_TREE
    7059        11591 :            && !DECL_RTL_SET_P (TREE_OPERAND (t1, 0)))
    7060        11591 :           || (TREE_CODE (TREE_OPERAND (t2, 0)) == VAR_DECL
    7061            0 :               && DECL_NAME (TREE_OPERAND (t2, 0)) == NULL_TREE
    7062            0 :               && !DECL_RTL_SET_P (TREE_OPERAND (t2, 0))))
    7063              :         cmp = 1;
    7064              :       else
    7065            0 :         cmp = simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    7066              : 
    7067            0 :       if (cmp <= 0)
    7068              :         return cmp;
    7069              : 
    7070        11591 :       return simple_cst_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
    7071              : 
    7072            0 :     case WITH_CLEANUP_EXPR:
    7073            0 :       cmp = simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    7074            0 :       if (cmp <= 0)
    7075              :         return cmp;
    7076              : 
    7077            0 :       return simple_cst_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t1, 1));
    7078              : 
    7079          229 :     case COMPONENT_REF:
    7080          229 :       if (TREE_OPERAND (t1, 1) == TREE_OPERAND (t2, 1))
    7081          229 :         return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    7082              : 
    7083              :       return 0;
    7084              : 
    7085              :     case VAR_DECL:
    7086              :     case PARM_DECL:
    7087              :     case CONST_DECL:
    7088              :     case FUNCTION_DECL:
    7089              :       return 0;
    7090              : 
    7091      6254611 :     default:
    7092      6254611 :       if (POLY_INT_CST_P (t1))
    7093              :         /* A false return means maybe_ne rather than known_ne.  */
    7094              :         return known_eq (poly_widest_int::from (poly_int_cst_value (t1),
    7095              :                                                 TYPE_SIGN (TREE_TYPE (t1))),
    7096              :                          poly_widest_int::from (poly_int_cst_value (t2),
    7097              :                                                 TYPE_SIGN (TREE_TYPE (t2))));
    7098      6254611 :       break;
    7099              :     }
    7100              : 
    7101              :   /* This general rule works for most tree codes.  All exceptions should be
    7102              :      handled above.  If this is a language-specific tree code, we can't
    7103              :      trust what might be in the operand, so say we don't know
    7104              :      the situation.  */
    7105      6254611 :   if ((int) code1 >= (int) LAST_AND_UNUSED_TREE_CODE)
    7106              :     return -1;
    7107              : 
    7108       855711 :   switch (TREE_CODE_CLASS (code1))
    7109              :     {
    7110              :     case tcc_unary:
    7111              :     case tcc_binary:
    7112              :     case tcc_comparison:
    7113              :     case tcc_expression:
    7114              :     case tcc_reference:
    7115              :     case tcc_statement:
    7116              :       cmp = 1;
    7117         1481 :       for (i = 0; i < TREE_CODE_LENGTH (code1); i++)
    7118              :         {
    7119         1150 :           cmp = simple_cst_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i));
    7120         1150 :           if (cmp <= 0)
    7121              :             return cmp;
    7122              :         }
    7123              : 
    7124              :       return cmp;
    7125              : 
    7126              :     default:
    7127              :       return -1;
    7128              :     }
    7129              : }
    7130              : 
    7131              : /* Compare the value of T, an INTEGER_CST, with U, an unsigned integer value.
    7132              :    Return -1, 0, or 1 if the value of T is less than, equal to, or greater
    7133              :    than U, respectively.  */
    7134              : 
    7135              : int
    7136   1550782747 : compare_tree_int (const_tree t, unsigned HOST_WIDE_INT u)
    7137              : {
    7138   1550782747 :   if (tree_int_cst_sgn (t) < 0)
    7139              :     return -1;
    7140   1550782426 :   else if (!tree_fits_uhwi_p (t))
    7141              :     return 1;
    7142   1550782397 :   else if (TREE_INT_CST_LOW (t) == u)
    7143              :     return 0;
    7144   1381043683 :   else if (TREE_INT_CST_LOW (t) < u)
    7145              :     return -1;
    7146              :   else
    7147     13839905 :     return 1;
    7148              : }
    7149              : 
    7150              : /* Return true if SIZE represents a constant size that is in bounds of
    7151              :    what the middle-end and the backend accepts (covering not more than
    7152              :    half of the address-space).
    7153              :    When PERR is non-null, set *PERR on failure to the description of
    7154              :    why SIZE is not valid.  */
    7155              : 
    7156              : bool
    7157     68621266 : valid_constant_size_p (const_tree size, cst_size_error *perr /* = NULL */)
    7158              : {
    7159     68621266 :   if (POLY_INT_CST_P (size))
    7160              :     {
    7161              :       if (TREE_OVERFLOW (size))
    7162              :         return false;
    7163              :       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    7164              :         if (!valid_constant_size_p (POLY_INT_CST_COEFF (size, i)))
    7165              :           return false;
    7166              :       return true;
    7167              :     }
    7168              : 
    7169     68621266 :   cst_size_error error;
    7170     68621266 :   if (!perr)
    7171     62903377 :     perr = &error;
    7172              : 
    7173     68621266 :   if (TREE_CODE (size) != INTEGER_CST)
    7174              :     {
    7175            3 :       *perr = cst_size_not_constant;
    7176            3 :       return false;
    7177              :     }
    7178              : 
    7179     68621263 :   if (TREE_OVERFLOW_P (size))
    7180              :     {
    7181           60 :       *perr = cst_size_overflow;
    7182           60 :       return false;
    7183              :     }
    7184              : 
    7185     68621203 :   if (tree_int_cst_sgn (size) < 0)
    7186              :     {
    7187          419 :       *perr = cst_size_negative;
    7188          419 :       return false;
    7189              :     }
    7190    137241568 :   if (!tree_fits_uhwi_p (size)
    7191    137241568 :       || (wi::to_widest (TYPE_MAX_VALUE (sizetype))
    7192    137241568 :           < wi::to_widest (size) * 2))
    7193              :     {
    7194          624 :       *perr = cst_size_too_big;
    7195          624 :       return false;
    7196              :     }
    7197              : 
    7198              :   return true;
    7199              : }
    7200              : 
    7201              : /* Return the precision of the type, or for a complex or vector type the
    7202              :    precision of the type of its elements.  */
    7203              : 
    7204              : unsigned int
    7205   7761687017 : element_precision (const_tree type)
    7206              : {
    7207   7761687017 :   if (!TYPE_P (type))
    7208      6395733 :     type = TREE_TYPE (type);
    7209   7761687017 :   enum tree_code code = TREE_CODE (type);
    7210   7761687017 :   if (code == COMPLEX_TYPE || code == VECTOR_TYPE)
    7211     58091946 :     type = TREE_TYPE (type);
    7212              : 
    7213   7761687017 :   return TYPE_PRECISION (type);
    7214              : }
    7215              : 
    7216              : /* Return true if CODE represents an associative tree code.  Otherwise
    7217              :    return false.  */
    7218              : bool
    7219     37209634 : associative_tree_code (enum tree_code code)
    7220              : {
    7221     37209634 :   switch (code)
    7222              :     {
    7223              :     case BIT_IOR_EXPR:
    7224              :     case BIT_AND_EXPR:
    7225              :     case BIT_XOR_EXPR:
    7226              :     case PLUS_EXPR:
    7227              :     case MULT_EXPR:
    7228              :     case MIN_EXPR:
    7229              :     case MAX_EXPR:
    7230              :       return true;
    7231              : 
    7232     26162262 :     default:
    7233     26162262 :       break;
    7234              :     }
    7235     26162262 :   return false;
    7236              : }
    7237              : 
    7238              : /* Return true if CODE represents a commutative tree code.  Otherwise
    7239              :    return false.  */
    7240              : bool
    7241   1782134309 : commutative_tree_code (enum tree_code code)
    7242              : {
    7243   1782134309 :   switch (code)
    7244              :     {
    7245              :     case PLUS_EXPR:
    7246              :     case MULT_EXPR:
    7247              :     case MULT_HIGHPART_EXPR:
    7248              :     case MIN_EXPR:
    7249              :     case MAX_EXPR:
    7250              :     case BIT_IOR_EXPR:
    7251              :     case BIT_XOR_EXPR:
    7252              :     case BIT_AND_EXPR:
    7253              :     case NE_EXPR:
    7254              :     case EQ_EXPR:
    7255              :     case UNORDERED_EXPR:
    7256              :     case ORDERED_EXPR:
    7257              :     case UNEQ_EXPR:
    7258              :     case LTGT_EXPR:
    7259              :     case TRUTH_AND_EXPR:
    7260              :     case TRUTH_XOR_EXPR:
    7261              :     case TRUTH_OR_EXPR:
    7262              :     case WIDEN_MULT_EXPR:
    7263              :     case VEC_WIDEN_MULT_HI_EXPR:
    7264              :     case VEC_WIDEN_MULT_LO_EXPR:
    7265              :     case VEC_WIDEN_MULT_EVEN_EXPR:
    7266              :     case VEC_WIDEN_MULT_ODD_EXPR:
    7267              :       return true;
    7268              : 
    7269    950774579 :     default:
    7270    950774579 :       break;
    7271              :     }
    7272    950774579 :   return false;
    7273              : }
    7274              : 
    7275              : /* Return true if CODE represents a ternary tree code for which the
    7276              :    first two operands are commutative.  Otherwise return false.  */
    7277              : bool
    7278     99051431 : commutative_ternary_tree_code (enum tree_code code)
    7279              : {
    7280     99051431 :   switch (code)
    7281              :     {
    7282              :     case WIDEN_MULT_PLUS_EXPR:
    7283              :     case WIDEN_MULT_MINUS_EXPR:
    7284              :     case DOT_PROD_EXPR:
    7285              :       return true;
    7286              : 
    7287     99041580 :     default:
    7288     99041580 :       break;
    7289              :     }
    7290     99041580 :   return false;
    7291              : }
    7292              : 
    7293              : /* Returns true if CODE can overflow.  */
    7294              : 
    7295              : bool
    7296          717 : operation_can_overflow (enum tree_code code)
    7297              : {
    7298          717 :   switch (code)
    7299              :     {
    7300              :     case PLUS_EXPR:
    7301              :     case MINUS_EXPR:
    7302              :     case MULT_EXPR:
    7303              :     case LSHIFT_EXPR:
    7304              :       /* Can overflow in various ways.  */
    7305              :       return true;
    7306              :     case TRUNC_DIV_EXPR:
    7307              :     case EXACT_DIV_EXPR:
    7308              :     case FLOOR_DIV_EXPR:
    7309              :     case CEIL_DIV_EXPR:
    7310              :       /* For INT_MIN / -1.  */
    7311              :       return true;
    7312              :     case NEGATE_EXPR:
    7313              :     case ABS_EXPR:
    7314              :       /* For -INT_MIN.  */
    7315              :       return true;
    7316          205 :     default:
    7317              :       /* These operators cannot overflow.  */
    7318          205 :       return false;
    7319              :     }
    7320              : }
    7321              : 
    7322              : /* Returns true if CODE operating on operands of type TYPE doesn't overflow, or
    7323              :    ftrapv doesn't generate trapping insns for CODE.  */
    7324              : 
    7325              : bool
    7326       265747 : operation_no_trapping_overflow (tree type, enum tree_code code)
    7327              : {
    7328       265747 :   gcc_checking_assert (ANY_INTEGRAL_TYPE_P (type));
    7329              : 
    7330              :   /* We don't generate instructions that trap on overflow for complex or vector
    7331              :      types.  */
    7332       265747 :   if (!INTEGRAL_TYPE_P (type))
    7333              :     return true;
    7334              : 
    7335       265747 :   if (!TYPE_OVERFLOW_TRAPS (type))
    7336              :     return true;
    7337              : 
    7338          262 :   switch (code)
    7339              :     {
    7340              :     case PLUS_EXPR:
    7341              :     case MINUS_EXPR:
    7342              :     case MULT_EXPR:
    7343              :     case NEGATE_EXPR:
    7344              :     case ABS_EXPR:
    7345              :       /* These operators can overflow, and -ftrapv generates trapping code for
    7346              :          these.  */
    7347              :       return false;
    7348              :     case TRUNC_DIV_EXPR:
    7349              :     case EXACT_DIV_EXPR:
    7350              :     case FLOOR_DIV_EXPR:
    7351              :     case CEIL_DIV_EXPR:
    7352              :     case LSHIFT_EXPR:
    7353              :       /* These operators can overflow, but -ftrapv does not generate trapping
    7354              :          code for these.  */
    7355              :       return true;
    7356              :     default:
    7357              :       /* These operators cannot overflow.  */
    7358              :       return true;
    7359              :     }
    7360              : }
    7361              : 
    7362              : /* Constructors for pointer, array and function types.
    7363              :    (RECORD_TYPE, UNION_TYPE and ENUMERAL_TYPE nodes are
    7364              :    constructed by language-dependent code, not here.)  */
    7365              : 
    7366              : /* Construct, lay out and return the type of pointers to TO_TYPE with
    7367              :    mode MODE.  If MODE is VOIDmode, a pointer mode for the address
    7368              :    space of TO_TYPE will be picked.  If CAN_ALIAS_ALL is TRUE,
    7369              :    indicate this type can reference all of memory. If such a type has
    7370              :    already been constructed, reuse it.  */
    7371              : 
    7372              : tree
    7373   2652508667 : build_pointer_type_for_mode (tree to_type, machine_mode mode,
    7374              :                              bool can_alias_all)
    7375              : {
    7376   2652508667 :   tree t;
    7377   2652508667 :   bool could_alias = can_alias_all;
    7378              : 
    7379   2652508667 :   if (to_type == error_mark_node)
    7380              :     return error_mark_node;
    7381              : 
    7382   2652508661 :   if (mode == VOIDmode)
    7383              :     {
    7384   2521696693 :       addr_space_t as = TYPE_ADDR_SPACE (to_type);
    7385   2521696693 :       mode = targetm.addr_space.pointer_mode (as);
    7386              :     }
    7387              : 
    7388              :   /* If the pointed-to type has the may_alias attribute set, force
    7389              :      a TYPE_REF_CAN_ALIAS_ALL pointer to be generated.  */
    7390   2652508661 :   if (lookup_attribute ("may_alias", TYPE_ATTRIBUTES (to_type)))
    7391      4486351 :     can_alias_all = true;
    7392              : 
    7393              :   /* In some cases, languages will have things that aren't a POINTER_TYPE
    7394              :      (such as a RECORD_TYPE for fat pointers in Ada) as TYPE_POINTER_TO.
    7395              :      In that case, return that type without regard to the rest of our
    7396              :      operands.
    7397              : 
    7398              :      ??? This is a kludge, but consistent with the way this function has
    7399              :      always operated and there doesn't seem to be a good way to avoid this
    7400              :      at the moment.  */
    7401   2652508661 :   if (TYPE_POINTER_TO (to_type) != 0
    7402   2652508661 :       && TREE_CODE (TYPE_POINTER_TO (to_type)) != POINTER_TYPE)
    7403       160965 :     return TYPE_POINTER_TO (to_type);
    7404              : 
    7405              :   /* First, if we already have a type for pointers to TO_TYPE and it's
    7406              :      the proper mode, use it.  */
    7407   2653157036 :   for (t = TYPE_POINTER_TO (to_type); t; t = TYPE_NEXT_PTR_TO (t))
    7408   2499338363 :     if (TYPE_MODE (t) == mode && TYPE_REF_CAN_ALIAS_ALL (t) == can_alias_all)
    7409              :       return t;
    7410              : 
    7411    153818673 :   t = make_node (POINTER_TYPE);
    7412              : 
    7413    153818673 :   TREE_TYPE (t) = to_type;
    7414    153818673 :   SET_TYPE_MODE (t, mode);
    7415    153818673 :   TYPE_REF_CAN_ALIAS_ALL (t) = can_alias_all;
    7416    153818673 :   TYPE_NEXT_PTR_TO (t) = TYPE_POINTER_TO (to_type);
    7417    153818673 :   TYPE_POINTER_TO (to_type) = t;
    7418              : 
    7419              :   /* During LTO we do not set TYPE_CANONICAL of pointers and references.  */
    7420    153818673 :   if (TYPE_STRUCTURAL_EQUALITY_P (to_type) || in_lto_p)
    7421      5404802 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    7422    148413871 :   else if (TYPE_CANONICAL (to_type) != to_type || could_alias)
    7423     44172185 :     TYPE_CANONICAL (t)
    7424     88344370 :       = build_pointer_type_for_mode (TYPE_CANONICAL (to_type),
    7425              :                                      mode, false);
    7426              : 
    7427              :   /* Lay out the type.  This function has many callers that are concerned
    7428              :      with expression-construction, and this simplifies them all.  */
    7429    153818673 :   layout_type (t);
    7430              : 
    7431    153818673 :   return t;
    7432              : }
    7433              : 
    7434              : /* By default build pointers in ptr_mode.  */
    7435              : 
    7436              : tree
    7437   2520994769 : build_pointer_type (tree to_type)
    7438              : {
    7439   2520994769 :   return build_pointer_type_for_mode (to_type, VOIDmode, false);
    7440              : }
    7441              : 
    7442              : /* Same as build_pointer_type_for_mode, but for REFERENCE_TYPE.  */
    7443              : 
    7444              : tree
    7445    734087858 : build_reference_type_for_mode (tree to_type, machine_mode mode,
    7446              :                                bool can_alias_all)
    7447              : {
    7448    734087858 :   tree t;
    7449    734087858 :   bool could_alias = can_alias_all;
    7450              : 
    7451    734087858 :   if (to_type == error_mark_node)
    7452              :     return error_mark_node;
    7453              : 
    7454    734087858 :   if (mode == VOIDmode)
    7455              :     {
    7456    579600151 :       addr_space_t as = TYPE_ADDR_SPACE (to_type);
    7457    579600151 :       mode = targetm.addr_space.pointer_mode (as);
    7458              :     }
    7459              : 
    7460              :   /* If the pointed-to type has the may_alias attribute set, force
    7461              :      a TYPE_REF_CAN_ALIAS_ALL pointer to be generated.  */
    7462    734087858 :   if (lookup_attribute ("may_alias", TYPE_ATTRIBUTES (to_type)))
    7463       751533 :     can_alias_all = true;
    7464              : 
    7465              :   /* In some cases, languages will have things that aren't a REFERENCE_TYPE
    7466              :      (such as a RECORD_TYPE for fat pointers in Ada) as TYPE_REFERENCE_TO.
    7467              :      In that case, return that type without regard to the rest of our
    7468              :      operands.
    7469              : 
    7470              :      ??? This is a kludge, but consistent with the way this function has
    7471              :      always operated and there doesn't seem to be a good way to avoid this
    7472              :      at the moment.  */
    7473    734087858 :   if (TYPE_REFERENCE_TO (to_type) != 0
    7474    734087858 :       && TREE_CODE (TYPE_REFERENCE_TO (to_type)) != REFERENCE_TYPE)
    7475            0 :     return TYPE_REFERENCE_TO (to_type);
    7476              : 
    7477              :   /* First, if we already have a type for pointers to TO_TYPE and it's
    7478              :      the proper mode, use it.  */
    7479    734087858 :   for (t = TYPE_REFERENCE_TO (to_type); t; t = TYPE_NEXT_REF_TO (t))
    7480    641021522 :     if (TYPE_MODE (t) == mode && TYPE_REF_CAN_ALIAS_ALL (t) == can_alias_all)
    7481              :       return t;
    7482              : 
    7483     93066336 :   t = make_node (REFERENCE_TYPE);
    7484              : 
    7485     93066336 :   TREE_TYPE (t) = to_type;
    7486     93066336 :   SET_TYPE_MODE (t, mode);
    7487     93066336 :   TYPE_REF_CAN_ALIAS_ALL (t) = can_alias_all;
    7488     93066336 :   TYPE_NEXT_REF_TO (t) = TYPE_REFERENCE_TO (to_type);
    7489     93066336 :   TYPE_REFERENCE_TO (to_type) = t;
    7490              : 
    7491              :   /* During LTO we do not set TYPE_CANONICAL of pointers and references.  */
    7492     93066336 :   if (TYPE_STRUCTURAL_EQUALITY_P (to_type) || in_lto_p)
    7493      5041855 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    7494     88024481 :   else if (TYPE_CANONICAL (to_type) != to_type || could_alias)
    7495     52202579 :     TYPE_CANONICAL (t)
    7496    104405158 :       = build_reference_type_for_mode (TYPE_CANONICAL (to_type),
    7497              :                                        mode, false);
    7498              : 
    7499     93066336 :   layout_type (t);
    7500              : 
    7501     93066336 :   return t;
    7502              : }
    7503              : 
    7504              : 
    7505              : /* Build the node for the type of references-to-TO_TYPE by default
    7506              :    in ptr_mode.  */
    7507              : 
    7508              : tree
    7509     26908531 : build_reference_type (tree to_type)
    7510              : {
    7511     26908531 :   return build_reference_type_for_mode (to_type, VOIDmode, false);
    7512              : }
    7513              : 
    7514              : #define MAX_INT_CACHED_PREC \
    7515              :   (HOST_BITS_PER_WIDE_INT > 64 ? HOST_BITS_PER_WIDE_INT : 64)
    7516              : static GTY(()) tree nonstandard_integer_type_cache[2 * MAX_INT_CACHED_PREC + 2];
    7517              : 
    7518              : static void
    7519       266934 : clear_nonstandard_integer_type_cache (void)
    7520              : {
    7521     34968354 :   for (size_t i = 0 ; i < 2 * MAX_INT_CACHED_PREC + 2 ; i++)
    7522              :   {
    7523     34701420 :     nonstandard_integer_type_cache[i] = NULL;
    7524              :   }
    7525            0 : }
    7526              : 
    7527              : /* Builds a signed or unsigned integer type of precision PRECISION.
    7528              :    Used for C bitfields whose precision does not match that of
    7529              :    built-in target types.  */
    7530              : tree
    7531     64315959 : build_nonstandard_integer_type (unsigned HOST_WIDE_INT precision,
    7532              :                                 int unsignedp)
    7533              : {
    7534     64315959 :   tree itype, ret;
    7535              : 
    7536     64315959 :   if (unsignedp)
    7537     55390103 :     unsignedp = MAX_INT_CACHED_PREC + 1;
    7538              : 
    7539     64315959 :   if (precision <= MAX_INT_CACHED_PREC)
    7540              :     {
    7541     63918447 :       itype = nonstandard_integer_type_cache[precision + unsignedp];
    7542     63918447 :       if (itype)
    7543              :         return itype;
    7544              :     }
    7545              : 
    7546      1132378 :   itype = make_node (INTEGER_TYPE);
    7547      1132378 :   TYPE_PRECISION (itype) = precision;
    7548              : 
    7549      1132378 :   if (unsignedp)
    7550       743589 :     fixup_unsigned_type (itype);
    7551              :   else
    7552       388789 :     fixup_signed_type (itype);
    7553              : 
    7554      1132378 :   inchash::hash hstate;
    7555      1132378 :   inchash::add_expr (TYPE_MAX_VALUE (itype), hstate);
    7556      1132378 :   ret = type_hash_canon (hstate.end (), itype);
    7557      1132378 :   if (precision <= MAX_INT_CACHED_PREC)
    7558       734866 :     nonstandard_integer_type_cache[precision + unsignedp] = ret;
    7559              : 
    7560              :   return ret;
    7561              : }
    7562              : 
    7563              : #define MAX_BOOL_CACHED_PREC \
    7564              :   (HOST_BITS_PER_WIDE_INT > 64 ? HOST_BITS_PER_WIDE_INT : 64)
    7565              : static GTY(()) tree nonstandard_boolean_type_cache[MAX_BOOL_CACHED_PREC + 1];
    7566              : 
    7567              : /* Builds a boolean type of precision PRECISION.
    7568              :    Used for boolean vectors to choose proper vector element size.  */
    7569              : tree
    7570      2658831 : build_nonstandard_boolean_type (unsigned HOST_WIDE_INT precision)
    7571              : {
    7572      2658831 :   tree type;
    7573              : 
    7574      2658831 :   if (precision <= MAX_BOOL_CACHED_PREC)
    7575              :     {
    7576      2654754 :       type = nonstandard_boolean_type_cache[precision];
    7577      2654754 :       if (type)
    7578              :         return type;
    7579              :     }
    7580              : 
    7581        84426 :   type = make_node (BOOLEAN_TYPE);
    7582        84426 :   TYPE_PRECISION (type) = precision;
    7583        84426 :   fixup_signed_type (type);
    7584              : 
    7585        84426 :   if (precision <= MAX_INT_CACHED_PREC)
    7586        80349 :     nonstandard_boolean_type_cache[precision] = type;
    7587              : 
    7588              :   return type;
    7589              : }
    7590              : 
    7591              : static GTY(()) vec<tree, va_gc> *bitint_type_cache;
    7592              : 
    7593              : /* Builds a signed or unsigned _BitInt(PRECISION) type.  */
    7594              : tree
    7595        78665 : build_bitint_type (unsigned HOST_WIDE_INT precision, int unsignedp)
    7596              : {
    7597        78665 :   tree itype, ret;
    7598              : 
    7599        78665 :   gcc_checking_assert (precision >= 1);
    7600              : 
    7601        78665 :   if (unsignedp)
    7602        39182 :     unsignedp = MAX_INT_CACHED_PREC + 1;
    7603              : 
    7604        78665 :   if (bitint_type_cache == NULL)
    7605          830 :     vec_safe_grow_cleared (bitint_type_cache, 2 * MAX_INT_CACHED_PREC + 2);
    7606              : 
    7607        78665 :   if (precision <= MAX_INT_CACHED_PREC)
    7608              :     {
    7609        18709 :       itype = (*bitint_type_cache)[precision + unsignedp];
    7610        18709 :       if (itype)
    7611              :         return itype;
    7612              :     }
    7613              : 
    7614        62141 :   itype = make_node (BITINT_TYPE);
    7615        62141 :   TYPE_PRECISION (itype) = precision;
    7616              : 
    7617        62141 :   if (unsignedp)
    7618        31220 :     fixup_unsigned_type (itype);
    7619              :   else
    7620        30921 :     fixup_signed_type (itype);
    7621              : 
    7622        62141 :   hashval_t hash = type_hash_canon_hash (itype);
    7623        62141 :   ret = type_hash_canon (hash, itype);
    7624        62141 :   if (precision <= MAX_INT_CACHED_PREC)
    7625         2185 :     (*bitint_type_cache)[precision + unsignedp] = ret;
    7626              : 
    7627              :   return ret;
    7628              : }
    7629              : 
    7630              : /* Create a range of some discrete type TYPE (an INTEGER_TYPE, ENUMERAL_TYPE
    7631              :    or BOOLEAN_TYPE) with low bound LOWVAL and high bound HIGHVAL.  If SHARED
    7632              :    is true, reuse such a type that has already been constructed.  */
    7633              : 
    7634              : static tree
    7635     45108679 : build_range_type_1 (tree type, tree lowval, tree highval, bool shared)
    7636              : {
    7637     45108679 :   tree itype = make_node (INTEGER_TYPE);
    7638              : 
    7639     45108679 :   TREE_TYPE (itype) = type;
    7640              : 
    7641     45108679 :   TYPE_MIN_VALUE (itype) = fold_convert (type, lowval);
    7642     45108679 :   TYPE_MAX_VALUE (itype) = highval ? fold_convert (type, highval) : NULL;
    7643              : 
    7644     45108679 :   TYPE_PRECISION (itype) = TYPE_PRECISION (type);
    7645     45108679 :   SET_TYPE_MODE (itype, TYPE_MODE (type));
    7646     45108679 :   TYPE_SIZE (itype) = TYPE_SIZE (type);
    7647     45108679 :   TYPE_SIZE_UNIT (itype) = TYPE_SIZE_UNIT (type);
    7648     45108679 :   SET_TYPE_ALIGN (itype, TYPE_ALIGN (type));
    7649     45108679 :   TYPE_USER_ALIGN (itype) = TYPE_USER_ALIGN (type);
    7650     45108679 :   SET_TYPE_WARN_IF_NOT_ALIGN (itype, TYPE_WARN_IF_NOT_ALIGN (type));
    7651              : 
    7652     45108679 :   if (!shared)
    7653              :     return itype;
    7654              : 
    7655     45108679 :   if ((TYPE_MIN_VALUE (itype)
    7656     45108679 :        && TREE_CODE (TYPE_MIN_VALUE (itype)) != INTEGER_CST)
    7657     90216518 :       || (TYPE_MAX_VALUE (itype)
    7658     44547119 :           && TREE_CODE (TYPE_MAX_VALUE (itype)) != INTEGER_CST))
    7659              :     {
    7660              :       /* Since we cannot reliably merge this type, we need to compare it using
    7661              :          structural equality checks.  */
    7662      1221109 :       SET_TYPE_STRUCTURAL_EQUALITY (itype);
    7663      1221109 :       return itype;
    7664              :     }
    7665              : 
    7666     43887570 :   hashval_t hash = type_hash_canon_hash (itype);
    7667     43887570 :   itype = type_hash_canon (hash, itype);
    7668              : 
    7669     43887570 :   return itype;
    7670              : }
    7671              : 
    7672              : /* Wrapper around build_range_type_1 with SHARED set to true.  */
    7673              : 
    7674              : tree
    7675     45108679 : build_range_type (tree type, tree lowval, tree highval)
    7676              : {
    7677     45108679 :   return build_range_type_1 (type, lowval, highval, true);
    7678              : }
    7679              : 
    7680              : /* Wrapper around build_range_type_1 with SHARED set to false.  */
    7681              : 
    7682              : tree
    7683            0 : build_nonshared_range_type (tree type, tree lowval, tree highval)
    7684              : {
    7685            0 :   return build_range_type_1 (type, lowval, highval, false);
    7686              : }
    7687              : 
    7688              : /* Create a type of integers to be the TYPE_DOMAIN of an ARRAY_TYPE.
    7689              :    MAXVAL should be the maximum value in the domain
    7690              :    (one less than the length of the array).
    7691              : 
    7692              :    The maximum value that MAXVAL can have is INT_MAX for a HOST_WIDE_INT.
    7693              :    We don't enforce this limit, that is up to caller (e.g. language front end).
    7694              :    The limit exists because the result is a signed type and we don't handle
    7695              :    sizes that use more than one HOST_WIDE_INT.  */
    7696              : 
    7697              : tree
    7698     42140515 : build_index_type (tree maxval)
    7699              : {
    7700     42140515 :   return build_range_type (sizetype, size_zero_node, maxval);
    7701              : }
    7702              : 
    7703              : /* Return true if the debug information for TYPE, a subtype, should be emitted
    7704              :    as a subrange type.  If so, set LOWVAL to the low bound and HIGHVAL to the
    7705              :    high bound, respectively.  Sometimes doing so unnecessarily obfuscates the
    7706              :    debug info and doesn't reflect the source code.  */
    7707              : 
    7708              : bool
    7709           18 : subrange_type_for_debug_p (const_tree type, tree *lowval, tree *highval)
    7710              : {
    7711           18 :   tree base_type = TREE_TYPE (type), low, high;
    7712              : 
    7713              :   /* Subrange types have a base type which is an integral type.  */
    7714           18 :   if (!INTEGRAL_TYPE_P (base_type))
    7715              :     return false;
    7716              : 
    7717              :   /* Get the real bounds of the subtype.  */
    7718           18 :   if (lang_hooks.types.get_subrange_bounds)
    7719            0 :     lang_hooks.types.get_subrange_bounds (type, &low, &high);
    7720              :   else
    7721              :     {
    7722           18 :       low = TYPE_MIN_VALUE (type);
    7723           18 :       high = TYPE_MAX_VALUE (type);
    7724              :     }
    7725              : 
    7726              :   /* If the type and its base type have the same representation and the same
    7727              :      name, then the type is not a subrange but a copy of the base type.  */
    7728           18 :   if ((TREE_CODE (base_type) == INTEGER_TYPE
    7729           18 :        || TREE_CODE (base_type) == BOOLEAN_TYPE)
    7730           18 :       && int_size_in_bytes (type) == int_size_in_bytes (base_type)
    7731           18 :       && tree_int_cst_equal (low, TYPE_MIN_VALUE (base_type))
    7732            0 :       && tree_int_cst_equal (high, TYPE_MAX_VALUE (base_type))
    7733           18 :       && TYPE_IDENTIFIER (type) == TYPE_IDENTIFIER (base_type))
    7734              :     return false;
    7735              : 
    7736           18 :   if (lowval)
    7737           18 :     *lowval = low;
    7738           18 :   if (highval)
    7739           18 :     *highval = high;
    7740              :   return true;
    7741              : }
    7742              : 
    7743              : /* Construct, lay out and return the type of arrays of elements with ELT_TYPE
    7744              :    and number of elements specified by the range of values of INDEX_TYPE.
    7745              :    If TYPELESS_STORAGE is true, TYPE_TYPELESS_STORAGE flag is set on the type.
    7746              :    If SHARED is true, reuse such a type that has already been constructed.
    7747              :    If SET_CANONICAL is true, compute TYPE_CANONICAL from the element type.  */
    7748              : 
    7749              : tree
    7750     73283907 : build_array_type_1 (tree elt_type, tree index_type, bool typeless_storage,
    7751              :                     bool shared, bool set_canonical)
    7752              : {
    7753     73283907 :   tree t;
    7754              : 
    7755     73283907 :   if (TREE_CODE (elt_type) == FUNCTION_TYPE)
    7756              :     {
    7757            0 :       error ("arrays of functions are not meaningful");
    7758            0 :       elt_type = integer_type_node;
    7759              :     }
    7760              : 
    7761     73283907 :   t = make_node (ARRAY_TYPE);
    7762     73283907 :   TREE_TYPE (t) = elt_type;
    7763     73283907 :   TYPE_DOMAIN (t) = index_type;
    7764     73283907 :   TYPE_ADDR_SPACE (t) = TYPE_ADDR_SPACE (elt_type);
    7765     73283907 :   TYPE_TYPELESS_STORAGE (t) = typeless_storage;
    7766              : 
    7767              :   /* Set TYPE_STRUCTURAL_EQUALITY_P.  */
    7768     73283907 :   if (set_canonical
    7769     73283907 :       && (TYPE_STRUCTURAL_EQUALITY_P (elt_type)
    7770     73244374 :           || (index_type && TYPE_STRUCTURAL_EQUALITY_P (index_type))
    7771     72956085 :           || in_lto_p))
    7772       401751 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    7773              : 
    7774     73283907 :   layout_type (t);
    7775              : 
    7776     73283907 :   if (shared)
    7777              :     {
    7778     73283876 :       hashval_t hash = type_hash_canon_hash (t);
    7779     73283876 :       tree probe_type = t;
    7780     73283876 :       t = type_hash_canon (hash, t);
    7781     73283876 :       if (t != probe_type)
    7782              :         return t;
    7783              :     }
    7784              : 
    7785     11236328 :   if (TYPE_CANONICAL (t) == t && set_canonical)
    7786              :     {
    7787     10884188 :       if (TYPE_STRUCTURAL_EQUALITY_P (elt_type)
    7788     10884188 :           || (index_type && TYPE_STRUCTURAL_EQUALITY_P (index_type))
    7789     21768376 :           || in_lto_p)
    7790            0 :         gcc_unreachable ();
    7791     10884188 :       else if (TYPE_CANONICAL (elt_type) != elt_type
    7792     10884188 :                || (index_type && TYPE_CANONICAL (index_type) != index_type))
    7793       107326 :         TYPE_CANONICAL (t)
    7794       311433 :           = build_array_type_1 (TYPE_CANONICAL (elt_type),
    7795              :                                 index_type
    7796        96781 :                                 ? TYPE_CANONICAL (index_type) : NULL_TREE,
    7797              :                                 typeless_storage, shared, set_canonical);
    7798              :     }
    7799              : 
    7800              :   return t;
    7801              : }
    7802              : 
    7803              : /* Wrapper around build_array_type_1 with SHARED set to true.  */
    7804              : 
    7805              : tree
    7806     73176550 : build_array_type (tree elt_type, tree index_type, bool typeless_storage)
    7807              : {
    7808     73176550 :   return
    7809     73176550 :     build_array_type_1 (elt_type, index_type, typeless_storage, true, true);
    7810              : }
    7811              : 
    7812              : /* Wrapper around build_array_type_1 with SHARED set to false.  */
    7813              : 
    7814              : tree
    7815            0 : build_nonshared_array_type (tree elt_type, tree index_type)
    7816              : {
    7817            0 :   return build_array_type_1 (elt_type, index_type, false, false, true);
    7818              : }
    7819              : 
    7820              : /* Return a representation of ELT_TYPE[NELTS], using indices of type
    7821              :    sizetype.  */
    7822              : 
    7823              : tree
    7824      1721504 : build_array_type_nelts (tree elt_type, poly_uint64 nelts)
    7825              : {
    7826      1721504 :   return build_array_type (elt_type, build_index_type (size_int (nelts - 1)));
    7827              : }
    7828              : 
    7829              : /* Computes the canonical argument types from the argument type list
    7830              :    ARGTYPES.
    7831              : 
    7832              :    Upon return, *ANY_STRUCTURAL_P will be true iff either it was true
    7833              :    on entry to this function, or if any of the ARGTYPES are
    7834              :    structural.
    7835              : 
    7836              :    Upon return, *ANY_NONCANONICAL_P will be true iff either it was
    7837              :    true on entry to this function, or if any of the ARGTYPES are
    7838              :    non-canonical.
    7839              : 
    7840              :    Returns a canonical argument list, which may be ARGTYPES when the
    7841              :    canonical argument list is unneeded (i.e., *ANY_STRUCTURAL_P is
    7842              :    true) or would not differ from ARGTYPES.  */
    7843              : 
    7844              : static tree
    7845   1017141259 : maybe_canonicalize_argtypes (tree argtypes,
    7846              :                              bool *any_structural_p,
    7847              :                              bool *any_noncanonical_p)
    7848              : {
    7849   1017141259 :   tree arg;
    7850   1017141259 :   bool any_noncanonical_argtypes_p = false;
    7851              : 
    7852   3514848962 :   for (arg = argtypes; arg && !(*any_structural_p); arg = TREE_CHAIN (arg))
    7853              :     {
    7854   2497707703 :       if (!TREE_VALUE (arg) || TREE_VALUE (arg) == error_mark_node)
    7855              :         /* Fail gracefully by stating that the type is structural.  */
    7856        16419 :         *any_structural_p = true;
    7857   2497691284 :       else if (TYPE_STRUCTURAL_EQUALITY_P (TREE_VALUE (arg)))
    7858     35256931 :         *any_structural_p = true;
    7859   2462434353 :       else if (TYPE_CANONICAL (TREE_VALUE (arg)) != TREE_VALUE (arg)
    7860   2462434353 :                || TREE_PURPOSE (arg))
    7861              :         /* If the argument has a default argument, we consider it
    7862              :            non-canonical even though the type itself is canonical.
    7863              :            That way, different variants of function and method types
    7864              :            with default arguments will all point to the variant with
    7865              :            no defaults as their canonical type.  */
    7866              :         any_noncanonical_argtypes_p = true;
    7867              :     }
    7868              : 
    7869   1017141259 :   if (*any_structural_p)
    7870              :     return argtypes;
    7871              : 
    7872    920321658 :   if (any_noncanonical_argtypes_p)
    7873              :     {
    7874              :       /* Build the canonical list of argument types.  */
    7875              :       tree canon_argtypes = NULL_TREE;
    7876              :       bool is_void = false;
    7877              : 
    7878    893709781 :       for (arg = argtypes; arg; arg = TREE_CHAIN (arg))
    7879              :         {
    7880    685793819 :           if (arg == void_list_node)
    7881              :             is_void = true;
    7882              :           else
    7883    957793716 :             canon_argtypes = tree_cons (NULL_TREE,
    7884    478896858 :                                         TYPE_CANONICAL (TREE_VALUE (arg)),
    7885              :                                         canon_argtypes);
    7886              :         }
    7887              : 
    7888    207915962 :       canon_argtypes = nreverse (canon_argtypes);
    7889    207915962 :       if (is_void)
    7890    206896961 :         canon_argtypes = chainon (canon_argtypes, void_list_node);
    7891              : 
    7892              :       /* There is a non-canonical type.  */
    7893    207915962 :       *any_noncanonical_p = true;
    7894    207915962 :       return canon_argtypes;
    7895              :     }
    7896              : 
    7897              :   /* The canonical argument types are the same as ARGTYPES.  */
    7898              :   return argtypes;
    7899              : }
    7900              : 
    7901              : /* Construct, lay out and return
    7902              :    the type of functions returning type VALUE_TYPE
    7903              :    given arguments of types ARG_TYPES.
    7904              :    ARG_TYPES is a chain of TREE_LIST nodes whose TREE_VALUEs
    7905              :    are data type nodes for the arguments of the function.
    7906              :    NO_NAMED_ARGS_STDARG_P is true if this is a prototyped
    7907              :    variable-arguments function with (...) prototype (no named arguments).
    7908              :    If such a type has already been constructed, reuse it.  */
    7909              : 
    7910              : tree
    7911    675170504 : build_function_type (tree value_type, tree arg_types,
    7912              :                      bool no_named_args_stdarg_p)
    7913              : {
    7914    675170504 :   tree t;
    7915    675170504 :   inchash::hash hstate;
    7916    675170504 :   bool any_structural_p, any_noncanonical_p;
    7917    675170504 :   tree canon_argtypes;
    7918              : 
    7919    675170504 :   gcc_assert (arg_types != error_mark_node);
    7920              : 
    7921    675170504 :   if (TREE_CODE (value_type) == FUNCTION_TYPE)
    7922              :     {
    7923            0 :       error ("function return type cannot be function");
    7924            0 :       value_type = integer_type_node;
    7925              :     }
    7926              : 
    7927              :   /* Make a node of the sort we want.  */
    7928    675170504 :   t = make_node (FUNCTION_TYPE);
    7929    675170504 :   TREE_TYPE (t) = value_type;
    7930    675170504 :   TYPE_ARG_TYPES (t) = arg_types;
    7931    675170504 :   if (no_named_args_stdarg_p)
    7932              :     {
    7933      1203140 :       gcc_assert (arg_types == NULL_TREE);
    7934      1203140 :       TYPE_NO_NAMED_ARGS_STDARG_P (t) = 1;
    7935              :     }
    7936              : 
    7937              :   /* Set up the canonical type. */
    7938    675170504 :   any_structural_p   = TYPE_STRUCTURAL_EQUALITY_P (value_type);
    7939    675170504 :   any_noncanonical_p = TYPE_CANONICAL (value_type) != value_type;
    7940    675170504 :   canon_argtypes = maybe_canonicalize_argtypes (arg_types,
    7941              :                                                 &any_structural_p,
    7942              :                                                 &any_noncanonical_p);
    7943              :   /* Set TYPE_STRUCTURAL_EQUALITY_P early.  */
    7944    675170504 :   if (any_structural_p)
    7945     70253343 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    7946              : 
    7947              :   /* If we already have such a type, use the old one.  */
    7948    675170504 :   hashval_t hash = type_hash_canon_hash (t);
    7949    675170504 :   tree probe_type = t;
    7950    675170504 :   t = type_hash_canon (hash, t);
    7951    675170504 :   if (t != probe_type)
    7952              :     return t;
    7953              : 
    7954    436811643 :   if (any_structural_p)
    7955     56648420 :     gcc_assert (TYPE_STRUCTURAL_EQUALITY_P (t));
    7956    380163223 :   else if (any_noncanonical_p)
    7957     89004200 :     TYPE_CANONICAL (t) = build_function_type (TYPE_CANONICAL (value_type),
    7958              :                                               canon_argtypes,
    7959              :                                               no_named_args_stdarg_p);
    7960              : 
    7961    436811643 :   if (!COMPLETE_TYPE_P (t))
    7962            0 :     layout_type (t);
    7963              :   return t;
    7964              : }
    7965              : 
    7966              : /* Build a function type.  The RETURN_TYPE is the type returned by the
    7967              :    function.  If VAARGS is set, no void_type_node is appended to the
    7968              :    list.  ARGP must be always be terminated be a NULL_TREE.  */
    7969              : 
    7970              : static tree
    7971     15775733 : build_function_type_list_1 (bool vaargs, tree return_type, va_list argp)
    7972              : {
    7973     15775733 :   tree t, args, last;
    7974              : 
    7975     15775733 :   t = va_arg (argp, tree);
    7976     66343985 :   for (args = NULL_TREE; t != NULL_TREE; t = va_arg (argp, tree))
    7977     34792519 :     args = tree_cons (NULL_TREE, t, args);
    7978              : 
    7979     15775733 :   if (vaargs)
    7980              :     {
    7981      1077597 :       last = args;
    7982      1077597 :       if (args != NULL_TREE)
    7983       842283 :         args = nreverse (args);
    7984      1077597 :       gcc_assert (last != void_list_node);
    7985              :     }
    7986     14698136 :   else if (args == NULL_TREE)
    7987      1246952 :     args = void_list_node;
    7988              :   else
    7989              :     {
    7990     13451184 :       last = args;
    7991     13451184 :       args = nreverse (args);
    7992     13451184 :       TREE_CHAIN (last) = void_list_node;
    7993              :     }
    7994     15775733 :   args = build_function_type (return_type, args, vaargs && args == NULL_TREE);
    7995              : 
    7996     15775733 :   return args;
    7997              : }
    7998              : 
    7999              : /* Build a function type.  The RETURN_TYPE is the type returned by the
    8000              :    function.  If additional arguments are provided, they are
    8001              :    additional argument types.  The list of argument types must always
    8002              :    be terminated by NULL_TREE.  */
    8003              : 
    8004              : tree
    8005     14698136 : build_function_type_list (tree return_type, ...)
    8006              : {
    8007     14698136 :   tree args;
    8008     14698136 :   va_list p;
    8009              : 
    8010     14698136 :   va_start (p, return_type);
    8011     14698136 :   args = build_function_type_list_1 (false, return_type, p);
    8012     14698136 :   va_end (p);
    8013     14698136 :   return args;
    8014              : }
    8015              : 
    8016              : /* Build a variable argument function type.  The RETURN_TYPE is the
    8017              :    type returned by the function.  If additional arguments are provided,
    8018              :    they are additional argument types.  The list of argument types must
    8019              :    always be terminated by NULL_TREE.  */
    8020              : 
    8021              : tree
    8022      1077597 : build_varargs_function_type_list (tree return_type, ...)
    8023              : {
    8024      1077597 :   tree args;
    8025      1077597 :   va_list p;
    8026              : 
    8027      1077597 :   va_start (p, return_type);
    8028      1077597 :   args = build_function_type_list_1 (true, return_type, p);
    8029      1077597 :   va_end (p);
    8030              : 
    8031      1077597 :   return args;
    8032              : }
    8033              : 
    8034              : /* Build a function type.  RETURN_TYPE is the type returned by the
    8035              :    function; VAARGS indicates whether the function takes varargs.  The
    8036              :    function takes N named arguments, the types of which are provided in
    8037              :    ARG_TYPES.  */
    8038              : 
    8039              : static tree
    8040    123516888 : build_function_type_array_1 (bool vaargs, tree return_type, int n,
    8041              :                              tree *arg_types)
    8042              : {
    8043    123516888 :   int i;
    8044    123516888 :   tree t = vaargs ? NULL_TREE : void_list_node;
    8045              : 
    8046    404067466 :   for (i = n - 1; i >= 0; i--)
    8047    280550578 :     t = tree_cons (NULL_TREE, arg_types[i], t);
    8048              : 
    8049    123516888 :   return build_function_type (return_type, t, vaargs && n == 0);
    8050              : }
    8051              : 
    8052              : /* Build a function type.  RETURN_TYPE is the type returned by the
    8053              :    function.  The function takes N named arguments, the types of which
    8054              :    are provided in ARG_TYPES.  */
    8055              : 
    8056              : tree
    8057    116922837 : build_function_type_array (tree return_type, int n, tree *arg_types)
    8058              : {
    8059    116922837 :   return build_function_type_array_1 (false, return_type, n, arg_types);
    8060              : }
    8061              : 
    8062              : /* Build a variable argument function type.  RETURN_TYPE is the type
    8063              :    returned by the function.  The function takes N named arguments, the
    8064              :    types of which are provided in ARG_TYPES.  */
    8065              : 
    8066              : tree
    8067      6594051 : build_varargs_function_type_array (tree return_type, int n, tree *arg_types)
    8068              : {
    8069      6594051 :   return build_function_type_array_1 (true, return_type, n, arg_types);
    8070              : }
    8071              : 
    8072              : /* Build a METHOD_TYPE for a member of BASETYPE.  The RETTYPE (a TYPE)
    8073              :    and ARGTYPES (a TREE_LIST) are the return type and arguments types
    8074              :    for the method.  An implicit additional parameter (of type
    8075              :    pointer-to-BASETYPE) is added to the ARGTYPES.  */
    8076              : 
    8077              : tree
    8078    341970755 : build_method_type_directly (tree basetype,
    8079              :                             tree rettype,
    8080              :                             tree argtypes)
    8081              : {
    8082    341970755 :   tree t;
    8083    341970755 :   tree ptype;
    8084    341970755 :   bool any_structural_p, any_noncanonical_p;
    8085    341970755 :   tree canon_argtypes;
    8086              : 
    8087              :   /* Make a node of the sort we want.  */
    8088    341970755 :   t = make_node (METHOD_TYPE);
    8089              : 
    8090    341970755 :   TYPE_METHOD_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype);
    8091    341970755 :   TREE_TYPE (t) = rettype;
    8092    341970755 :   ptype = build_pointer_type (basetype);
    8093              : 
    8094              :   /* The actual arglist for this function includes a "hidden" argument
    8095              :      which is "this".  Put it into the list of argument types.  */
    8096    341970755 :   argtypes = tree_cons (NULL_TREE, ptype, argtypes);
    8097    341970755 :   TYPE_ARG_TYPES (t) = argtypes;
    8098              : 
    8099              :   /* Set up the canonical type. */
    8100    341970755 :   any_structural_p
    8101    341970755 :     = (TYPE_STRUCTURAL_EQUALITY_P (basetype)
    8102    341970755 :        || TYPE_STRUCTURAL_EQUALITY_P (rettype));
    8103    341970755 :   any_noncanonical_p
    8104    341970755 :     = (TYPE_CANONICAL (basetype) != basetype
    8105    341970755 :        || TYPE_CANONICAL (rettype) != rettype);
    8106    341970755 :   canon_argtypes = maybe_canonicalize_argtypes (TREE_CHAIN (argtypes),
    8107              :                                                 &any_structural_p,
    8108              :                                                 &any_noncanonical_p);
    8109              : 
    8110              :   /* Set TYPE_STRUCTURAL_EQUALITY_P early.  */
    8111    341970755 :   if (any_structural_p)
    8112     26566258 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    8113              : 
    8114              :   /* If we already have such a type, use the old one.  */
    8115    341970755 :   hashval_t hash = type_hash_canon_hash (t);
    8116    341970755 :   tree probe_type = t;
    8117    341970755 :   t = type_hash_canon (hash, t);
    8118    341970755 :   if (t != probe_type)
    8119              :     return t;
    8120              : 
    8121    263703926 :   if (any_structural_p)
    8122     22434815 :     gcc_assert (TYPE_STRUCTURAL_EQUALITY_P (t));
    8123    241269111 :   else if (any_noncanonical_p)
    8124     88743891 :     TYPE_CANONICAL (t)
    8125    177487782 :       = build_method_type_directly (TYPE_CANONICAL (basetype),
    8126     88743891 :                                     TYPE_CANONICAL (rettype),
    8127              :                                     canon_argtypes);
    8128    263703926 :   if (!COMPLETE_TYPE_P (t))
    8129            0 :     layout_type (t);
    8130              : 
    8131              :   return t;
    8132              : }
    8133              : 
    8134              : /* Construct, lay out and return the type of methods belonging to class
    8135              :    BASETYPE and whose arguments and values are described by TYPE.
    8136              :    If that type exists already, reuse it.
    8137              :    TYPE must be a FUNCTION_TYPE node.  */
    8138              : 
    8139              : tree
    8140            0 : build_method_type (tree basetype, tree type)
    8141              : {
    8142            0 :   gcc_assert (TREE_CODE (type) == FUNCTION_TYPE);
    8143              : 
    8144            0 :   return build_method_type_directly (basetype,
    8145            0 :                                      TREE_TYPE (type),
    8146            0 :                                      TYPE_ARG_TYPES (type));
    8147              : }
    8148              : 
    8149              : /* Construct, lay out and return the type of offsets to a value
    8150              :    of type TYPE, within an object of type BASETYPE.
    8151              :    If a suitable offset type exists already, reuse it.  */
    8152              : 
    8153              : tree
    8154       984097 : build_offset_type (tree basetype, tree type)
    8155              : {
    8156       984097 :   tree t;
    8157              : 
    8158              :   /* Make a node of the sort we want.  */
    8159       984097 :   t = make_node (OFFSET_TYPE);
    8160              : 
    8161       984097 :   TYPE_OFFSET_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype);
    8162       984097 :   TREE_TYPE (t) = type;
    8163       984097 :   if (TYPE_STRUCTURAL_EQUALITY_P (basetype)
    8164       984097 :       || TYPE_STRUCTURAL_EQUALITY_P (type))
    8165            4 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    8166              : 
    8167              :   /* If we already have such a type, use the old one.  */
    8168       984097 :   hashval_t hash = type_hash_canon_hash (t);
    8169       984097 :   tree probe_type = t;
    8170       984097 :   t = type_hash_canon (hash, t);
    8171       984097 :   if (t != probe_type)
    8172              :     return t;
    8173              : 
    8174       237437 :   if (!COMPLETE_TYPE_P (t))
    8175            0 :     layout_type (t);
    8176              : 
    8177       237437 :   if (TYPE_CANONICAL (t) == t)
    8178              :     {
    8179       237433 :       if (TYPE_STRUCTURAL_EQUALITY_P (basetype)
    8180       237433 :           || TYPE_STRUCTURAL_EQUALITY_P (type))
    8181            0 :         gcc_unreachable ();
    8182       237433 :       else if (TYPE_CANONICAL (TYPE_MAIN_VARIANT (basetype)) != basetype
    8183       237433 :                || TYPE_CANONICAL (type) != type)
    8184       136180 :         TYPE_CANONICAL (t)
    8185       272360 :           = build_offset_type (TYPE_CANONICAL (TYPE_MAIN_VARIANT (basetype)),
    8186       136180 :                                TYPE_CANONICAL (type));
    8187              :     }
    8188              : 
    8189              :   return t;
    8190              : }
    8191              : 
    8192              : /* Create a complex type whose components are COMPONENT_TYPE.
    8193              : 
    8194              :    If NAMED is true, the type is given a TYPE_NAME.  We do not always
    8195              :    do so because this creates a DECL node and thus make the DECL_UIDs
    8196              :    dependent on the type canonicalization hashtable, which is GC-ed,
    8197              :    so the DECL_UIDs would not be stable wrt garbage collection.  */
    8198              : 
    8199              : tree
    8200      5499140 : build_complex_type (tree component_type, bool named)
    8201              : {
    8202      5499140 :   gcc_assert (INTEGRAL_TYPE_P (component_type)
    8203              :               || SCALAR_FLOAT_TYPE_P (component_type)
    8204              :               || FIXED_POINT_TYPE_P (component_type));
    8205              : 
    8206              :   /* Make a node of the sort we want.  */
    8207      5499140 :   tree probe = make_node (COMPLEX_TYPE);
    8208              : 
    8209      5499140 :   TREE_TYPE (probe) = TYPE_MAIN_VARIANT (component_type);
    8210      5499140 :   if (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (probe)))
    8211            0 :     SET_TYPE_STRUCTURAL_EQUALITY (probe);
    8212              : 
    8213              :   /* If we already have such a type, use the old one.  */
    8214      5499140 :   hashval_t hash = type_hash_canon_hash (probe);
    8215      5499140 :   tree t = type_hash_canon (hash, probe);
    8216              : 
    8217      5499140 :   if (t == probe)
    8218              :     {
    8219              :       /* We created a new type.  The hash insertion will have laid
    8220              :          out the type.  We need to check the canonicalization and
    8221              :          maybe set the name.  */
    8222      3236239 :       gcc_checking_assert (COMPLETE_TYPE_P (t)
    8223              :                            && !TYPE_NAME (t));
    8224              : 
    8225      3236239 :       if (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (t)))
    8226              :         ;
    8227      3236239 :       else if (TYPE_CANONICAL (TREE_TYPE (t)) != TREE_TYPE (t))
    8228          111 :         TYPE_CANONICAL (t)
    8229          222 :           = build_complex_type (TYPE_CANONICAL (TREE_TYPE (t)), named);
    8230              : 
    8231              :       /* We need to create a name, since complex is a fundamental type.  */
    8232      3236239 :       if (named)
    8233              :         {
    8234      1187516 :           const char *name = NULL;
    8235              : 
    8236      1187516 :           if (TREE_TYPE (t) == char_type_node)
    8237              :             name = "complex char";
    8238      1187516 :           else if (TREE_TYPE (t) == signed_char_type_node)
    8239              :             name = "complex signed char";
    8240      1187516 :           else if (TREE_TYPE (t) == unsigned_char_type_node)
    8241              :             name = "complex unsigned char";
    8242      1187516 :           else if (TREE_TYPE (t) == short_integer_type_node)
    8243              :             name = "complex short int";
    8244      1187516 :           else if (TREE_TYPE (t) == short_unsigned_type_node)
    8245              :             name = "complex short unsigned int";
    8246      1187516 :           else if (TREE_TYPE (t) == integer_type_node)
    8247              :             name = "complex int";
    8248       890637 :           else if (TREE_TYPE (t) == unsigned_type_node)
    8249              :             name = "complex unsigned int";
    8250       890637 :           else if (TREE_TYPE (t) == long_integer_type_node)
    8251              :             name = "complex long int";
    8252       890637 :           else if (TREE_TYPE (t) == long_unsigned_type_node)
    8253              :             name = "complex long unsigned int";
    8254       890637 :           else if (TREE_TYPE (t) == long_long_integer_type_node)
    8255              :             name = "complex long long int";
    8256       890637 :           else if (TREE_TYPE (t) == long_long_unsigned_type_node)
    8257              :             name = "complex long long unsigned int";
    8258              : 
    8259              :           if (name != NULL)
    8260       296879 :             TYPE_NAME (t) = build_decl (UNKNOWN_LOCATION, TYPE_DECL,
    8261              :                                         get_identifier (name), t);
    8262              :         }
    8263              :     }
    8264              : 
    8265      5499140 :   return build_qualified_type (t, TYPE_QUALS (component_type));
    8266              : }
    8267              : 
    8268              : /* If TYPE is a real or complex floating-point type and the target
    8269              :    does not directly support arithmetic on TYPE then return the wider
    8270              :    type to be used for arithmetic on TYPE.  Otherwise, return
    8271              :    NULL_TREE.  */
    8272              : 
    8273              : tree
    8274     91848876 : excess_precision_type (tree type)
    8275              : {
    8276              :   /* The target can give two different responses to the question of
    8277              :      which excess precision mode it would like depending on whether we
    8278              :      are in -fexcess-precision=standard or -fexcess-precision=fast.  */
    8279              : 
    8280      3560682 :   enum excess_precision_type requested_type
    8281     91848876 :     = (flag_excess_precision == EXCESS_PRECISION_FAST
    8282     91848876 :        ? EXCESS_PRECISION_TYPE_FAST
    8283              :        : (flag_excess_precision == EXCESS_PRECISION_FLOAT16
    8284      3561408 :           ? EXCESS_PRECISION_TYPE_FLOAT16 : EXCESS_PRECISION_TYPE_STANDARD));
    8285              : 
    8286     91848876 :   enum flt_eval_method target_flt_eval_method
    8287     91848876 :     = targetm.c.excess_precision (requested_type);
    8288              : 
    8289              :   /* The target should not ask for unpredictable float evaluation (though
    8290              :      it might advertise that implicitly the evaluation is unpredictable,
    8291              :      but we don't care about that here, it will have been reported
    8292              :      elsewhere).  If it does ask for unpredictable evaluation, we have
    8293              :      nothing to do here.  */
    8294     91848876 :   gcc_assert (target_flt_eval_method != FLT_EVAL_METHOD_UNPREDICTABLE);
    8295              : 
    8296              :   /* Nothing to do.  The target has asked for all types we know about
    8297              :      to be computed with their native precision and range.  */
    8298     91848876 :   if (target_flt_eval_method == FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16)
    8299              :     return NULL_TREE;
    8300              : 
    8301              :   /* The target will promote this type in a target-dependent way, so excess
    8302              :      precision ought to leave it alone.  */
    8303     90210168 :   if (targetm.promoted_type (type) != NULL_TREE)
    8304              :     return NULL_TREE;
    8305              : 
    8306     90210168 :   machine_mode float16_type_mode = (float16_type_node
    8307     90210168 :                                     ? TYPE_MODE (float16_type_node)
    8308     90210168 :                                     : VOIDmode);
    8309     90210168 :   machine_mode bfloat16_type_mode = (bfloat16_type_node
    8310     90210168 :                                      ? TYPE_MODE (bfloat16_type_node)
    8311     90210168 :                                      : VOIDmode);
    8312     90210168 :   machine_mode float_type_mode = TYPE_MODE (float_type_node);
    8313     90210168 :   machine_mode double_type_mode = TYPE_MODE (double_type_node);
    8314              : 
    8315     90210168 :   switch (TREE_CODE (type))
    8316              :     {
    8317     60513312 :     case REAL_TYPE:
    8318     60513312 :       {
    8319     60513312 :         machine_mode type_mode = TYPE_MODE (type);
    8320     60513312 :         switch (target_flt_eval_method)
    8321              :           {
    8322     60500479 :           case FLT_EVAL_METHOD_PROMOTE_TO_FLOAT:
    8323     60500479 :             if (type_mode == float16_type_mode
    8324     60500479 :                 || type_mode == bfloat16_type_mode)
    8325       284428 :               return float_type_node;
    8326              :             break;
    8327            0 :           case FLT_EVAL_METHOD_PROMOTE_TO_DOUBLE:
    8328            0 :             if (type_mode == float16_type_mode
    8329            0 :                 || type_mode == bfloat16_type_mode
    8330            0 :                 || type_mode == float_type_mode)
    8331            0 :               return double_type_node;
    8332              :             break;
    8333        12833 :           case FLT_EVAL_METHOD_PROMOTE_TO_LONG_DOUBLE:
    8334        12833 :             if (type_mode == float16_type_mode
    8335        12833 :                 || type_mode == bfloat16_type_mode
    8336        12828 :                 || type_mode == float_type_mode
    8337        12828 :                 || type_mode == double_type_mode)
    8338        12384 :               return long_double_type_node;
    8339              :             break;
    8340            0 :           default:
    8341            0 :             gcc_unreachable ();
    8342              :           }
    8343              :         break;
    8344              :       }
    8345       378992 :     case COMPLEX_TYPE:
    8346       378992 :       {
    8347       378992 :         if (TREE_CODE (TREE_TYPE (type)) != REAL_TYPE)
    8348              :           return NULL_TREE;
    8349       369455 :         machine_mode type_mode = TYPE_MODE (TREE_TYPE (type));
    8350       369455 :         switch (target_flt_eval_method)
    8351              :           {
    8352       369122 :           case FLT_EVAL_METHOD_PROMOTE_TO_FLOAT:
    8353       369122 :             if (type_mode == float16_type_mode
    8354       369122 :                 || type_mode == bfloat16_type_mode)
    8355          281 :               return complex_float_type_node;
    8356              :             break;
    8357            0 :           case FLT_EVAL_METHOD_PROMOTE_TO_DOUBLE:
    8358            0 :             if (type_mode == float16_type_mode
    8359            0 :                 || type_mode == bfloat16_type_mode
    8360            0 :                 || type_mode == float_type_mode)
    8361            0 :               return complex_double_type_node;
    8362              :             break;
    8363          333 :           case FLT_EVAL_METHOD_PROMOTE_TO_LONG_DOUBLE:
    8364          333 :             if (type_mode == float16_type_mode
    8365          333 :                 || type_mode == bfloat16_type_mode
    8366          333 :                 || type_mode == float_type_mode
    8367          333 :                 || type_mode == double_type_mode)
    8368          281 :               return complex_long_double_type_node;
    8369              :             break;
    8370            0 :           default:
    8371            0 :             gcc_unreachable ();
    8372              :           }
    8373              :         break;
    8374              :       }
    8375              :     default:
    8376              :       break;
    8377              :     }
    8378              : 
    8379              :   return NULL_TREE;
    8380              : }
    8381              : 
    8382              : /* Return OP, stripped of any conversions to wider types as much as is safe.
    8383              :    Converting the value back to OP's type makes a value equivalent to OP.
    8384              : 
    8385              :    If FOR_TYPE is nonzero, we return a value which, if converted to
    8386              :    type FOR_TYPE, would be equivalent to converting OP to type FOR_TYPE.
    8387              : 
    8388              :    OP must have integer, real or enumeral type.  Pointers are not allowed!
    8389              : 
    8390              :    There are some cases where the obvious value we could return
    8391              :    would regenerate to OP if converted to OP's type,
    8392              :    but would not extend like OP to wider types.
    8393              :    If FOR_TYPE indicates such extension is contemplated, we eschew such values.
    8394              :    For example, if OP is (unsigned short)(signed char)-1,
    8395              :    we avoid returning (signed char)-1 if FOR_TYPE is int,
    8396              :    even though extending that to an unsigned short would regenerate OP,
    8397              :    since the result of extending (signed char)-1 to (int)
    8398              :    is different from (int) OP.  */
    8399              : 
    8400              : tree
    8401     11766253 : get_unwidened (tree op, tree for_type)
    8402              : {
    8403              :   /* Set UNS initially if converting OP to FOR_TYPE is a zero-extension.  */
    8404     11766253 :   tree type = TREE_TYPE (op);
    8405     11766253 :   unsigned final_prec
    8406     19674181 :     = TYPE_PRECISION (for_type != 0 ? for_type : type);
    8407     11766253 :   int uns
    8408     11766253 :     = (for_type != 0 && for_type != type
    8409      3452249 :        && final_prec > TYPE_PRECISION (type)
    8410     12009204 :        && TYPE_UNSIGNED (type));
    8411     11766253 :   tree win = op;
    8412              : 
    8413     12136679 :   while (CONVERT_EXPR_P (op))
    8414              :     {
    8415       370519 :       int bitschange;
    8416              : 
    8417              :       /* TYPE_PRECISION on vector types has different meaning
    8418              :          (TYPE_VECTOR_SUBPARTS) and casts from vectors are view conversions,
    8419              :          so avoid them here.  */
    8420       370519 :       if (TREE_CODE (TREE_TYPE (TREE_OPERAND (op, 0))) == VECTOR_TYPE)
    8421              :         break;
    8422              : 
    8423       370519 :       bitschange = TYPE_PRECISION (TREE_TYPE (op))
    8424       370519 :                    - TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op, 0)));
    8425              : 
    8426              :       /* Truncations are many-one so cannot be removed.
    8427              :          Unless we are later going to truncate down even farther.  */
    8428       370519 :       if (bitschange < 0
    8429       370519 :           && final_prec > TYPE_PRECISION (TREE_TYPE (op)))
    8430              :         break;
    8431              : 
    8432              :       /* See what's inside this conversion.  If we decide to strip it,
    8433              :          we will set WIN.  */
    8434       370426 :       op = TREE_OPERAND (op, 0);
    8435              : 
    8436              :       /* If we have not stripped any zero-extensions (uns is 0),
    8437              :          we can strip any kind of extension.
    8438              :          If we have previously stripped a zero-extension,
    8439              :          only zero-extensions can safely be stripped.
    8440              :          Any extension can be stripped if the bits it would produce
    8441              :          are all going to be discarded later by truncating to FOR_TYPE.  */
    8442              : 
    8443       370426 :       if (bitschange > 0)
    8444              :         {
    8445       227384 :           if (! uns || final_prec <= TYPE_PRECISION (TREE_TYPE (op)))
    8446              :             win = op;
    8447              :           /* TYPE_UNSIGNED says whether this is a zero-extension.
    8448              :              Let's avoid computing it if it does not affect WIN
    8449              :              and if UNS will not be needed again.  */
    8450       227384 :           if ((uns
    8451       227353 :                || CONVERT_EXPR_P (op))
    8452       228112 :               && TYPE_UNSIGNED (TREE_TYPE (op)))
    8453              :             {
    8454              :               uns = 1;
    8455              :               win = op;
    8456              :             }
    8457              :         }
    8458              :     }
    8459              : 
    8460              :   /* If we finally reach a constant see if it fits in sth smaller and
    8461              :      in that case convert it.  */
    8462     11766253 :   if (TREE_CODE (win) == INTEGER_CST)
    8463              :     {
    8464       571605 :       tree wtype = TREE_TYPE (win);
    8465       571605 :       unsigned prec = wi::min_precision (wi::to_wide (win), TYPE_SIGN (wtype));
    8466       571605 :       if (for_type)
    8467       559844 :         prec = MAX (prec, final_prec);
    8468       571605 :       if (prec < TYPE_PRECISION (wtype))
    8469              :         {
    8470       566996 :           tree t = lang_hooks.types.type_for_size (prec, TYPE_UNSIGNED (wtype));
    8471       566996 :           if (t && TYPE_PRECISION (t) < TYPE_PRECISION (wtype))
    8472       555193 :             win = fold_convert (t, win);
    8473              :         }
    8474              :     }
    8475              : 
    8476     11766253 :   return win;
    8477              : }
    8478              : 
    8479              : /* Return OP or a simpler expression for a narrower value
    8480              :    which can be sign-extended or zero-extended to give back OP.
    8481              :    Store in *UNSIGNEDP_PTR either 1 if the value should be zero-extended
    8482              :    or 0 if the value should be sign-extended.  */
    8483              : 
    8484              : tree
    8485     85463934 : get_narrower (tree op, int *unsignedp_ptr)
    8486              : {
    8487     85463934 :   int uns = 0;
    8488     85463934 :   bool first = true;
    8489     85463934 :   tree win = op;
    8490     85463934 :   bool integral_p = INTEGRAL_TYPE_P (TREE_TYPE (op));
    8491              : 
    8492     85463934 :   if (TREE_CODE (op) == COMPOUND_EXPR)
    8493              :     {
    8494        90994 :       do
    8495        90994 :         op = TREE_OPERAND (op, 1);
    8496        90994 :       while (TREE_CODE (op) == COMPOUND_EXPR);
    8497        90979 :       tree ret = get_narrower (op, unsignedp_ptr);
    8498        90979 :       if (ret == op)
    8499              :         return win;
    8500         4262 :       auto_vec <tree, 16> v;
    8501         4262 :       unsigned int i;
    8502         8531 :       for (op = win; TREE_CODE (op) == COMPOUND_EXPR;
    8503         4269 :            op = TREE_OPERAND (op, 1))
    8504         4269 :         v.safe_push (op);
    8505        17055 :       FOR_EACH_VEC_ELT_REVERSE (v, i, op)
    8506         4269 :         ret = build2_loc (EXPR_LOCATION (op), COMPOUND_EXPR,
    8507         4269 :                           TREE_TYPE (ret), TREE_OPERAND (op, 0),
    8508              :                           ret);
    8509         4262 :       return ret;
    8510         4262 :     }
    8511    101726038 :   while (TREE_CODE (op) == NOP_EXPR)
    8512              :     {
    8513     16386106 :       int bitschange
    8514     16386106 :         = (TYPE_PRECISION (TREE_TYPE (op))
    8515     16386106 :            - TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op, 0))));
    8516              : 
    8517              :       /* Truncations are many-one so cannot be removed.  */
    8518     16386106 :       if (bitschange < 0)
    8519              :         break;
    8520              : 
    8521              :       /* See what's inside this conversion.  If we decide to strip it,
    8522              :          we will set WIN.  */
    8523              : 
    8524     16353179 :       if (bitschange > 0)
    8525              :         {
    8526      3856777 :           op = TREE_OPERAND (op, 0);
    8527              :           /* An extension: the outermost one can be stripped,
    8528              :              but remember whether it is zero or sign extension.  */
    8529      3856777 :           if (first)
    8530      3845855 :             uns = TYPE_UNSIGNED (TREE_TYPE (op));
    8531              :           /* Otherwise, if a sign extension has been stripped,
    8532              :              only sign extensions can now be stripped;
    8533              :              if a zero extension has been stripped, only zero-extensions.  */
    8534        10922 :           else if (uns != TYPE_UNSIGNED (TREE_TYPE (op)))
    8535              :             break;
    8536              :           first = false;
    8537              :         }
    8538              :       else /* bitschange == 0 */
    8539              :         {
    8540              :           /* A change in nominal type can always be stripped, but we must
    8541              :              preserve the unsignedness.  */
    8542     12496402 :           if (first)
    8543     11904708 :             uns = TYPE_UNSIGNED (TREE_TYPE (op));
    8544     12496402 :           first = false;
    8545     12496402 :           op = TREE_OPERAND (op, 0);
    8546              :           /* Keep trying to narrow, but don't assign op to win if it
    8547              :              would turn an integral type into something else.  */
    8548     23229635 :           if (INTEGRAL_TYPE_P (TREE_TYPE (op)) != integral_p)
    8549        99222 :             continue;
    8550              :         }
    8551              : 
    8552     16253861 :       win = op;
    8553              :     }
    8554              : 
    8555     85372955 :   if (TREE_CODE (op) == COMPONENT_REF
    8556              :       /* Since type_for_size always gives an integer type.  */
    8557      2975013 :       && TREE_CODE (TREE_TYPE (op)) != REAL_TYPE
    8558      2872115 :       && TREE_CODE (TREE_TYPE (op)) != FIXED_POINT_TYPE
    8559              :       /* Ensure field is laid out already.  */
    8560      2872115 :       && DECL_SIZE (TREE_OPERAND (op, 1)) != 0
    8561     88245067 :       && tree_fits_uhwi_p (DECL_SIZE (TREE_OPERAND (op, 1))))
    8562              :     {
    8563      2872112 :       unsigned HOST_WIDE_INT innerprec
    8564      2872112 :         = tree_to_uhwi (DECL_SIZE (TREE_OPERAND (op, 1)));
    8565      2872112 :       int unsignedp = (DECL_UNSIGNED (TREE_OPERAND (op, 1))
    8566      2872112 :                        || TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op, 1))));
    8567      2872112 :       tree type = lang_hooks.types.type_for_size (innerprec, unsignedp);
    8568              : 
    8569              :       /* We can get this structure field in a narrower type that fits it,
    8570              :          but the resulting extension to its nominal type (a fullword type)
    8571              :          must satisfy the same conditions as for other extensions.
    8572              : 
    8573              :          Do this only for fields that are aligned (not bit-fields),
    8574              :          because when bit-field insns will be used there is no
    8575              :          advantage in doing this.  */
    8576              : 
    8577      2872112 :       if (innerprec < TYPE_PRECISION (TREE_TYPE (op))
    8578            0 :           && ! DECL_BIT_FIELD (TREE_OPERAND (op, 1))
    8579            0 :           && (first || uns == DECL_UNSIGNED (TREE_OPERAND (op, 1)))
    8580      2872112 :           && type != 0)
    8581              :         {
    8582            0 :           if (first)
    8583            0 :             uns = DECL_UNSIGNED (TREE_OPERAND (op, 1));
    8584            0 :           win = fold_convert (type, op);
    8585              :         }
    8586              :     }
    8587              : 
    8588     85372955 :   *unsignedp_ptr = uns;
    8589     85372955 :   return win;
    8590              : }
    8591              : 
    8592              : /* Return true if integer constant C has a value that is permissible
    8593              :    for TYPE, an integral type.  */
    8594              : 
    8595              : bool
    8596    198733197 : int_fits_type_p (const_tree c, const_tree type)
    8597              : {
    8598    198733197 :   tree type_low_bound, type_high_bound;
    8599    198733197 :   bool ok_for_low_bound, ok_for_high_bound;
    8600    198733197 :   signop sgn_c = TYPE_SIGN (TREE_TYPE (c));
    8601              : 
    8602              :   /* Non-standard boolean types can have arbitrary precision but various
    8603              :      transformations assume that they can only take values 0 and +/-1.  */
    8604    198733197 :   if (TREE_CODE (type) == BOOLEAN_TYPE)
    8605      1286424 :     return wi::fits_to_boolean_p (wi::to_wide (c), type);
    8606              : 
    8607    197446773 : retry:
    8608    197458622 :   type_low_bound = TYPE_MIN_VALUE (type);
    8609    197458622 :   type_high_bound = TYPE_MAX_VALUE (type);
    8610              : 
    8611              :   /* If at least one bound of the type is a constant integer, we can check
    8612              :      ourselves and maybe make a decision. If no such decision is possible, but
    8613              :      this type is a subtype, try checking against that.  Otherwise, use
    8614              :      fits_to_tree_p, which checks against the precision.
    8615              : 
    8616              :      Compute the status for each possibly constant bound, and return if we see
    8617              :      one does not match. Use ok_for_xxx_bound for this purpose, assigning -1
    8618              :      for "unknown if constant fits", 0 for "constant known *not* to fit" and 1
    8619              :      for "constant known to fit".  */
    8620              : 
    8621              :   /* Check if c >= type_low_bound.  */
    8622    197458622 :   if (type_low_bound && TREE_CODE (type_low_bound) == INTEGER_CST)
    8623              :     {
    8624    197458622 :       if (tree_int_cst_lt (c, type_low_bound))
    8625              :         return false;
    8626              :       ok_for_low_bound = true;
    8627              :     }
    8628              :   else
    8629              :     ok_for_low_bound = false;
    8630              : 
    8631              :   /* Check if c <= type_high_bound.  */
    8632    197204291 :   if (type_high_bound && TREE_CODE (type_high_bound) == INTEGER_CST)
    8633              :     {
    8634    197172694 :       if (tree_int_cst_lt (type_high_bound, c))
    8635              :         return false;
    8636              :       ok_for_high_bound = true;
    8637              :     }
    8638              :   else
    8639              :     ok_for_high_bound = false;
    8640              : 
    8641              :   /* If the constant fits both bounds, the result is known.  */
    8642    195259980 :   if (ok_for_low_bound && ok_for_high_bound)
    8643              :     return true;
    8644              : 
    8645              :   /* Perform some generic filtering which may allow making a decision
    8646              :      even if the bounds are not constant.  First, negative integers
    8647              :      never fit in unsigned types, */
    8648        31597 :   if (TYPE_UNSIGNED (type) && sgn_c == SIGNED && wi::neg_p (wi::to_wide (c)))
    8649            0 :     return false;
    8650              : 
    8651              :   /* Second, narrower types always fit in wider ones.  */
    8652        31597 :   if (TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (c)))
    8653              :     return true;
    8654              : 
    8655              :   /* Third, unsigned integers with top bit set never fit signed types.  */
    8656        11858 :   if (!TYPE_UNSIGNED (type) && sgn_c == UNSIGNED)
    8657              :     {
    8658           14 :       int prec = GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (TREE_TYPE (c))) - 1;
    8659           14 :       if (prec < TYPE_PRECISION (TREE_TYPE (c)))
    8660              :         {
    8661              :           /* When a tree_cst is converted to a wide-int, the precision
    8662              :              is taken from the type.  However, if the precision of the
    8663              :              mode underneath the type is smaller than that, it is
    8664              :              possible that the value will not fit.  The test below
    8665              :              fails if any bit is set between the sign bit of the
    8666              :              underlying mode and the top bit of the type.  */
    8667           14 :           if (wi::zext (wi::to_wide (c), prec - 1) != wi::to_wide (c))
    8668              :             return false;
    8669              :         }
    8670            0 :       else if (wi::neg_p (wi::to_wide (c)))
    8671              :         return false;
    8672              :     }
    8673              : 
    8674              :   /* If we haven't been able to decide at this point, there nothing more we
    8675              :      can check ourselves here.  Look at the base type if we have one and it
    8676              :      has the same precision.  */
    8677        11849 :   if (TREE_CODE (type) == INTEGER_TYPE
    8678        11849 :       && TREE_TYPE (type) != 0
    8679        23698 :       && TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (type)))
    8680              :     {
    8681        11849 :       type = TREE_TYPE (type);
    8682        11849 :       goto retry;
    8683              :     }
    8684              : 
    8685              :   /* Or to fits_to_tree_p, if nothing else.  */
    8686            0 :   return wi::fits_to_tree_p (wi::to_wide (c), type);
    8687              : }
    8688              : 
    8689              : /* Stores bounds of an integer TYPE in MIN and MAX.  If TYPE has non-constant
    8690              :    bounds or is a POINTER_TYPE, the maximum and/or minimum values that can be
    8691              :    represented (assuming two's-complement arithmetic) within the bit
    8692              :    precision of the type are returned instead.  */
    8693              : 
    8694              : void
    8695     23599474 : get_type_static_bounds (const_tree type, mpz_t min, mpz_t max)
    8696              : {
    8697     22107990 :   if (!POINTER_TYPE_P (type) && TYPE_MIN_VALUE (type)
    8698     45707464 :       && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST)
    8699     22107990 :     wi::to_mpz (wi::to_wide (TYPE_MIN_VALUE (type)), min, TYPE_SIGN (type));
    8700              :   else
    8701              :     {
    8702      1491484 :       if (TYPE_UNSIGNED (type))
    8703      1491484 :         mpz_set_ui (min, 0);
    8704              :       else
    8705              :         {
    8706            0 :           wide_int mn = wi::min_value (TYPE_PRECISION (type), SIGNED);
    8707            0 :           wi::to_mpz (mn, min, SIGNED);
    8708            0 :         }
    8709              :     }
    8710              : 
    8711     22107990 :   if (!POINTER_TYPE_P (type) && TYPE_MAX_VALUE (type)
    8712     45707464 :       && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST)
    8713     22107990 :     wi::to_mpz (wi::to_wide (TYPE_MAX_VALUE (type)), max, TYPE_SIGN (type));
    8714              :   else
    8715              :     {
    8716      1491484 :       wide_int mn = wi::max_value (TYPE_PRECISION (type), TYPE_SIGN (type));
    8717      1491484 :       wi::to_mpz (mn, max, TYPE_SIGN (type));
    8718      1491484 :     }
    8719     23599474 : }
    8720              : 
    8721              : /* Return true if VAR is an automatic variable.  */
    8722              : 
    8723              : bool
    8724   1242390682 : auto_var_p (const_tree var)
    8725              : {
    8726   1025833307 :   return ((((VAR_P (var) && ! DECL_EXTERNAL (var))
    8727    222094781 :             || TREE_CODE (var) == PARM_DECL)
    8728   1119579161 :            && ! TREE_STATIC (var))
    8729   1392590432 :           || TREE_CODE (var) == RESULT_DECL);
    8730              : }
    8731              : 
    8732              : /* Return true if VAR is an automatic variable defined in function FN.  */
    8733              : 
    8734              : bool
    8735   1843843126 : auto_var_in_fn_p (const_tree var, const_tree fn)
    8736              : {
    8737    621927193 :   return (DECL_P (var) && DECL_CONTEXT (var) == fn
    8738   2245076929 :           && (auto_var_p (var)
    8739      6321170 :               || TREE_CODE (var) == LABEL_DECL));
    8740              : }
    8741              : 
    8742              : /* Subprogram of following function.  Called by walk_tree.
    8743              : 
    8744              :    Return *TP if it is an automatic variable or parameter of the
    8745              :    function passed in as DATA.  */
    8746              : 
    8747              : static tree
    8748       128641 : find_var_from_fn (tree *tp, int *walk_subtrees, void *data)
    8749              : {
    8750       128641 :   tree fn = (tree) data;
    8751              : 
    8752       128641 :   if (TYPE_P (*tp))
    8753            0 :     *walk_subtrees = 0;
    8754              : 
    8755       128641 :   else if (DECL_P (*tp)
    8756       128641 :            && auto_var_in_fn_p (*tp, fn))
    8757       120045 :     return *tp;
    8758              : 
    8759              :   return NULL_TREE;
    8760              : }
    8761              : 
    8762              : /* Returns true if T is, contains, or refers to a type with variable
    8763              :    size.  For METHOD_TYPEs and FUNCTION_TYPEs we exclude the
    8764              :    arguments, but not the return type.  If FN is nonzero, only return
    8765              :    true if a modifier of the type or position of FN is a variable or
    8766              :    parameter inside FN.
    8767              : 
    8768              :    This concept is more general than that of C99 'variably modified types':
    8769              :    in C99, a struct type is never variably modified because a VLA may not
    8770              :    appear as a structure member.  However, in GNU C code like:
    8771              : 
    8772              :      struct S { int i[f()]; };
    8773              : 
    8774              :    is valid, and other languages may define similar constructs.  */
    8775              : 
    8776              : bool
    8777   2444262643 : variably_modified_type_p (tree type, tree fn)
    8778              : {
    8779   2444262643 :   tree t;
    8780              : 
    8781              : /* Test if T is either variable (if FN is zero) or an expression containing
    8782              :    a variable in FN.  If TYPE isn't gimplified, return true also if
    8783              :    gimplify_one_sizepos would gimplify the expression into a local
    8784              :    variable.  */
    8785              : #define RETURN_TRUE_IF_VAR(T)                                           \
    8786              :   do { tree _t = (T);                                                   \
    8787              :     if (_t != NULL_TREE                                                 \
    8788              :         && _t != error_mark_node                                        \
    8789              :         && !CONSTANT_CLASS_P (_t)                                       \
    8790              :         && TREE_CODE (_t) != PLACEHOLDER_EXPR                           \
    8791              :         && (!fn                                                         \
    8792              :             || (!TYPE_SIZES_GIMPLIFIED (type)                           \
    8793              :                 && (TREE_CODE (_t) != VAR_DECL                          \
    8794              :                     && !CONTAINS_PLACEHOLDER_P (_t)))                   \
    8795              :             || walk_tree (&_t, find_var_from_fn, fn, NULL)))                \
    8796              :       return true;  } while (0)
    8797              : 
    8798   2444262643 :   if (type == error_mark_node)
    8799              :     return false;
    8800              : 
    8801              :   /* If TYPE itself has variable size, it is variably modified.  */
    8802   2444262258 :   RETURN_TRUE_IF_VAR (TYPE_SIZE (type));
    8803   2444118549 :   RETURN_TRUE_IF_VAR (TYPE_SIZE_UNIT (type));
    8804              : 
    8805   2444117925 :   switch (TREE_CODE (type))
    8806              :     {
    8807    655868572 :     case POINTER_TYPE:
    8808    655868572 :     case REFERENCE_TYPE:
    8809    655868572 :     case VECTOR_TYPE:
    8810              :       /* Ada can have pointer types referring to themselves indirectly.  */
    8811    655868572 :       if (TREE_VISITED (type))
    8812              :         return false;
    8813    655868572 :       TREE_VISITED (type) = true;
    8814    655868572 :       if (variably_modified_type_p (TREE_TYPE (type), fn))
    8815              :         {
    8816        82271 :           TREE_VISITED (type) = false;
    8817        82271 :           return true;
    8818              :         }
    8819    655786301 :       TREE_VISITED (type) = false;
    8820    655786301 :       break;
    8821              : 
    8822    138821914 :     case FUNCTION_TYPE:
    8823    138821914 :     case METHOD_TYPE:
    8824              :       /* If TYPE is a function type, it is variably modified if the
    8825              :          return type is variably modified.  */
    8826    138821914 :       if (variably_modified_type_p (TREE_TYPE (type), fn))
    8827              :           return true;
    8828              :       break;
    8829              : 
    8830    601960392 :     case INTEGER_TYPE:
    8831    601960392 :     case REAL_TYPE:
    8832    601960392 :     case FIXED_POINT_TYPE:
    8833    601960392 :     case ENUMERAL_TYPE:
    8834    601960392 :     case BOOLEAN_TYPE:
    8835              :       /* Scalar types are variably modified if their end points
    8836              :          aren't constant.  */
    8837    601960392 :       RETURN_TRUE_IF_VAR (TYPE_MIN_VALUE (type));
    8838    601960392 :       RETURN_TRUE_IF_VAR (TYPE_MAX_VALUE (type));
    8839    601923818 :       break;
    8840              : 
    8841    849326869 :     case RECORD_TYPE:
    8842    849326869 :     case UNION_TYPE:
    8843    849326869 :     case QUAL_UNION_TYPE:
    8844              :       /* We can't see if any of the fields are variably-modified by the
    8845              :          definition we normally use, since that would produce infinite
    8846              :          recursion via pointers.  */
    8847              :       /* This is variably modified if some field's type is.  */
    8848  39257203197 :       for (t = TYPE_FIELDS (type); t; t = DECL_CHAIN (t))
    8849  38407876328 :         if (TREE_CODE (t) == FIELD_DECL)
    8850              :           {
    8851   1238993895 :             RETURN_TRUE_IF_VAR (DECL_FIELD_OFFSET (t));
    8852   1238993895 :             RETURN_TRUE_IF_VAR (DECL_SIZE (t));
    8853   1238993895 :             RETURN_TRUE_IF_VAR (DECL_SIZE_UNIT (t));
    8854              : 
    8855              :             /* If the type is a qualified union, then the DECL_QUALIFIER
    8856              :                of fields can also be an expression containing a variable.  */
    8857   1238993895 :             if (TREE_CODE (type) == QUAL_UNION_TYPE)
    8858            0 :               RETURN_TRUE_IF_VAR (DECL_QUALIFIER (t));
    8859              : 
    8860              :             /* If the field is a qualified union, then it's only a container
    8861              :                for what's inside so we look into it.  That's necessary in LTO
    8862              :                mode because the sizes of the field tested above have been set
    8863              :                to PLACEHOLDER_EXPRs by free_lang_data.  */
    8864   1238993895 :             if (TREE_CODE (TREE_TYPE (t)) == QUAL_UNION_TYPE
    8865   1238993895 :                 && variably_modified_type_p (TREE_TYPE (t), fn))
    8866              :               return true;
    8867              :           }
    8868              :       break;
    8869              : 
    8870     14693426 :     case ARRAY_TYPE:
    8871              :       /* Do not call ourselves to avoid infinite recursion.  This is
    8872              :          variably modified if the element type is.  */
    8873     14693426 :       RETURN_TRUE_IF_VAR (TYPE_SIZE (TREE_TYPE (type)));
    8874     14689968 :       RETURN_TRUE_IF_VAR (TYPE_SIZE_UNIT (TREE_TYPE (type)));
    8875     14689942 :       break;
    8876              : 
    8877              :     default:
    8878              :       break;
    8879              :     }
    8880              : 
    8881              :   /* The current language may have other cases to check, but in general,
    8882              :      all other types are not variably modified.  */
    8883   2443995366 :   return lang_hooks.tree_inlining.var_mod_type_p (type, fn);
    8884              : 
    8885              : #undef RETURN_TRUE_IF_VAR
    8886              : }
    8887              : 
    8888              : /* Given a DECL or TYPE, return the scope in which it was declared, or
    8889              :    NULL_TREE if there is no containing scope.  */
    8890              : 
    8891              : tree
    8892   2976975630 : get_containing_scope (const_tree t)
    8893              : {
    8894   2976975630 :   return (TYPE_P (t) ? TYPE_CONTEXT (t) : DECL_CONTEXT (t));
    8895              : }
    8896              : 
    8897              : /* Returns the ultimate TRANSLATION_UNIT_DECL context of DECL or NULL.  */
    8898              : 
    8899              : const_tree
    8900        14484 : get_ultimate_context (const_tree decl)
    8901              : {
    8902        39753 :   while (decl && TREE_CODE (decl) != TRANSLATION_UNIT_DECL)
    8903              :     {
    8904        25269 :       if (TREE_CODE (decl) == BLOCK)
    8905            0 :         decl = BLOCK_SUPERCONTEXT (decl);
    8906              :       else
    8907        25269 :         decl = get_containing_scope (decl);
    8908              :     }
    8909        14484 :   return decl;
    8910              : }
    8911              : 
    8912              : /* Return the innermost context enclosing DECL that is
    8913              :    a FUNCTION_DECL, or zero if none.  */
    8914              : 
    8915              : tree
    8916   1504477776 : decl_function_context (const_tree decl)
    8917              : {
    8918   1504477776 :   tree context;
    8919              : 
    8920   1504477776 :   if (TREE_CODE (decl) == ERROR_MARK)
    8921              :     return 0;
    8922              : 
    8923              :   /* C++ virtual functions use DECL_CONTEXT for the class of the vtable
    8924              :      where we look up the function at runtime.  Such functions always take
    8925              :      a first argument of type 'pointer to real context'.
    8926              : 
    8927              :      C++ should really be fixed to use DECL_CONTEXT for the real context,
    8928              :      and use something else for the "virtual context".  */
    8929   1504477776 :   else if (TREE_CODE (decl) == FUNCTION_DECL && DECL_VIRTUAL_P (decl))
    8930      4827728 :     context
    8931      4827728 :       = TYPE_MAIN_VARIANT
    8932              :         (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)))));
    8933              :   else
    8934   1499650048 :     context = DECL_CONTEXT (decl);
    8935              : 
    8936   3637180780 :   while (context && TREE_CODE (context) != FUNCTION_DECL)
    8937              :     {
    8938   2132703004 :       if (TREE_CODE (context) == BLOCK)
    8939            0 :         context = BLOCK_SUPERCONTEXT (context);
    8940              :       else
    8941   2132703004 :         context = get_containing_scope (context);
    8942              :     }
    8943              : 
    8944              :   return context;
    8945              : }
    8946              : 
    8947              : /* Return the innermost context enclosing DECL that is
    8948              :    a RECORD_TYPE, UNION_TYPE or QUAL_UNION_TYPE, or zero if none.
    8949              :    TYPE_DECLs and FUNCTION_DECLs are transparent to this function.  */
    8950              : 
    8951              : tree
    8952     98088135 : decl_type_context (const_tree decl)
    8953              : {
    8954     98088135 :   tree context = DECL_CONTEXT (decl);
    8955              : 
    8956    101246383 :   while (context)
    8957     95471434 :     switch (TREE_CODE (context))
    8958              :       {
    8959              :       case NAMESPACE_DECL:
    8960              :       case TRANSLATION_UNIT_DECL:
    8961              :         return NULL_TREE;
    8962              : 
    8963              :       case RECORD_TYPE:
    8964              :       case UNION_TYPE:
    8965              :       case QUAL_UNION_TYPE:
    8966              :         return context;
    8967              : 
    8968      3158248 :       case TYPE_DECL:
    8969      3158248 :       case FUNCTION_DECL:
    8970      3158248 :         context = DECL_CONTEXT (context);
    8971      3158248 :         break;
    8972              : 
    8973            0 :       case BLOCK:
    8974            0 :         context = BLOCK_SUPERCONTEXT (context);
    8975            0 :         break;
    8976              : 
    8977            0 :       default:
    8978            0 :         gcc_unreachable ();
    8979              :       }
    8980              : 
    8981              :   return NULL_TREE;
    8982              : }
    8983              : 
    8984              : /* CALL is a CALL_EXPR.  Return the declaration for the function
    8985              :    called, or NULL_TREE if the called function cannot be
    8986              :    determined.  */
    8987              : 
    8988              : tree
    8989   1254695835 : get_callee_fndecl (const_tree call)
    8990              : {
    8991   1254695835 :   tree addr;
    8992              : 
    8993   1254695835 :   if (call == error_mark_node)
    8994              :     return error_mark_node;
    8995              : 
    8996              :   /* It's invalid to call this function with anything but a
    8997              :      CALL_EXPR.  */
    8998   1254695835 :   gcc_assert (TREE_CODE (call) == CALL_EXPR);
    8999              : 
    9000              :   /* The first operand to the CALL is the address of the function
    9001              :      called.  */
    9002   1254695835 :   addr = CALL_EXPR_FN (call);
    9003              : 
    9004              :   /* If there is no function, return early.  */
    9005   1254695835 :   if (addr == NULL_TREE)
    9006              :     return NULL_TREE;
    9007              : 
    9008   1251947263 :   STRIP_NOPS (addr);
    9009              : 
    9010              :   /* If this is a readonly function pointer, extract its initial value.  */
    9011     21057339 :   if (DECL_P (addr) && TREE_CODE (addr) != FUNCTION_DECL
    9012      2486373 :       && TREE_READONLY (addr) && ! TREE_THIS_VOLATILE (addr)
    9013   1252611780 :       && DECL_INITIAL (addr))
    9014       664462 :     addr = DECL_INITIAL (addr);
    9015              : 
    9016              :   /* If the address is just `&f' for some function `f', then we know
    9017              :      that `f' is being called.  */
    9018   1251947263 :   if (TREE_CODE (addr) == ADDR_EXPR
    9019   1251947263 :       && TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL)
    9020   1197587819 :     return TREE_OPERAND (addr, 0);
    9021              : 
    9022              :   /* We couldn't figure out what was being called.  */
    9023              :   return NULL_TREE;
    9024              : }
    9025              : 
    9026              : /* Return true when STMTs arguments and return value match those of FNDECL,
    9027              :    a decl of a builtin function.  */
    9028              : 
    9029              : static bool
    9030      6430049 : tree_builtin_call_types_compatible_p (const_tree call, tree fndecl)
    9031              : {
    9032      6430049 :   gcc_checking_assert (DECL_BUILT_IN_CLASS (fndecl) != NOT_BUILT_IN);
    9033              : 
    9034      6430049 :   if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
    9035      6430049 :     if (tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl)))
    9036      6430049 :       fndecl = decl;
    9037              : 
    9038      6430049 :   bool gimple_form = (cfun && (cfun->curr_properties & PROP_gimple)) != 0;
    9039      6430049 :   if (gimple_form
    9040        16086 :       ? !useless_type_conversion_p (TREE_TYPE (call),
    9041        16086 :                                     TREE_TYPE (TREE_TYPE (fndecl)))
    9042      6413963 :       : (TYPE_MAIN_VARIANT (TREE_TYPE (call))
    9043      6413963 :          != TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl)))))
    9044              :     return false;
    9045              : 
    9046      6429833 :   tree targs = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
    9047      6429833 :   unsigned nargs = call_expr_nargs (call);
    9048     16238683 :   for (unsigned i = 0; i < nargs; ++i, targs = TREE_CHAIN (targs))
    9049              :     {
    9050              :       /* Variadic args follow.  */
    9051     11344387 :       if (!targs)
    9052              :         return true;
    9053      9809507 :       tree arg = CALL_EXPR_ARG (call, i);
    9054      9809507 :       tree type = TREE_VALUE (targs);
    9055      9809507 :       if (gimple_form
    9056      9809507 :           ? !useless_type_conversion_p (type, TREE_TYPE (arg))
    9057      9793421 :           : TYPE_MAIN_VARIANT (type) != TYPE_MAIN_VARIANT (TREE_TYPE (arg)))
    9058              :         {
    9059              :           /* For pointer arguments be more forgiving, e.g. due to
    9060              :              FILE * vs. fileptr_type_node, or say char * vs. const char *
    9061              :              differences etc.  */
    9062      1132555 :           if (!gimple_form
    9063       566606 :               && POINTER_TYPE_P (type)
    9064       566054 :               && POINTER_TYPE_P (TREE_TYPE (arg))
    9065      1132555 :               && tree_nop_conversion_p (type, TREE_TYPE (arg)))
    9066       565949 :             continue;
    9067              :           return false;
    9068              :         }
    9069              :     }
    9070      9787945 :   if (targs && !VOID_TYPE_P (TREE_VALUE (targs)))
    9071            5 :     return false;
    9072              :   return true;
    9073              : }
    9074              : 
    9075              : /* If CALL_EXPR CALL calls a normal built-in function or an internal function,
    9076              :    return the associated function code, otherwise return CFN_LAST.  */
    9077              : 
    9078              : combined_fn
    9079     42110342 : get_call_combined_fn (const_tree call)
    9080              : {
    9081              :   /* It's invalid to call this function with anything but a CALL_EXPR.  */
    9082     42110342 :   gcc_assert (TREE_CODE (call) == CALL_EXPR);
    9083              : 
    9084     42110342 :   if (!CALL_EXPR_FN (call))
    9085        62869 :     return as_combined_fn (CALL_EXPR_IFN (call));
    9086              : 
    9087     42047473 :   tree fndecl = get_callee_fndecl (call);
    9088     42047473 :   if (fndecl
    9089     42024643 :       && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
    9090     48477522 :       && tree_builtin_call_types_compatible_p (call, fndecl))
    9091      6429171 :     return as_combined_fn (DECL_FUNCTION_CODE (fndecl));
    9092              : 
    9093              :   return CFN_LAST;
    9094              : }
    9095              : 
    9096              : /* Comparator of indices based on tree_node_counts.  */
    9097              : 
    9098              : static int
    9099            0 : tree_nodes_cmp (const void *p1, const void *p2)
    9100              : {
    9101            0 :   const unsigned *n1 = (const unsigned *)p1;
    9102            0 :   const unsigned *n2 = (const unsigned *)p2;
    9103              : 
    9104            0 :   return tree_node_counts[*n1] - tree_node_counts[*n2];
    9105              : }
    9106              : 
    9107              : /* Comparator of indices based on tree_code_counts.  */
    9108              : 
    9109              : static int
    9110            0 : tree_codes_cmp (const void *p1, const void *p2)
    9111              : {
    9112            0 :   const unsigned *n1 = (const unsigned *)p1;
    9113            0 :   const unsigned *n2 = (const unsigned *)p2;
    9114              : 
    9115            0 :   return tree_code_counts[*n1] - tree_code_counts[*n2];
    9116              : }
    9117              : 
    9118              : #define TREE_MEM_USAGE_SPACES 40
    9119              : 
    9120              : /* Print debugging information about tree nodes generated during the compile,
    9121              :    and any language-specific information.  */
    9122              : 
    9123              : void
    9124            0 : dump_tree_statistics (void)
    9125              : {
    9126            0 :   if (GATHER_STATISTICS)
    9127              :     {
    9128              :       uint64_t total_nodes, total_bytes;
    9129              :       fprintf (stderr, "\nKind                   Nodes      Bytes\n");
    9130              :       mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
    9131              :       total_nodes = total_bytes = 0;
    9132              : 
    9133              :       {
    9134              :         auto_vec<unsigned> indices (all_kinds);
    9135              :         for (unsigned i = 0; i < all_kinds; i++)
    9136              :           indices.quick_push (i);
    9137              :         indices.qsort (tree_nodes_cmp);
    9138              : 
    9139              :         for (unsigned i = 0; i < (int) all_kinds; i++)
    9140              :           {
    9141              :             unsigned j = indices[i];
    9142              :             fprintf (stderr, "%-20s %6" PRIu64 "%c %9" PRIu64 "%c\n",
    9143              :                      tree_node_kind_names[j], SIZE_AMOUNT (tree_node_counts[j]),
    9144              :                      SIZE_AMOUNT (tree_node_sizes[j]));
    9145              :             total_nodes += tree_node_counts[j];
    9146              :             total_bytes += tree_node_sizes[j];
    9147              :           }
    9148              :         mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
    9149              :         fprintf (stderr, "%-20s %6" PRIu64 "%c %9" PRIu64 "%c\n", "Total",
    9150              :                  SIZE_AMOUNT (total_nodes), SIZE_AMOUNT (total_bytes));
    9151              :         mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
    9152              :       }
    9153              : 
    9154              :       {
    9155              :         fprintf (stderr, "Code                              Nodes\n");
    9156              :         mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
    9157              : 
    9158              :         auto_vec<unsigned> indices (MAX_TREE_CODES);
    9159              :         for (unsigned i = 0; i < MAX_TREE_CODES; i++)
    9160              :           indices.quick_push (i);
    9161              :         indices.qsort (tree_codes_cmp);
    9162              : 
    9163              :         for (unsigned i = 0; i < MAX_TREE_CODES; i++)
    9164              :           {
    9165              :             unsigned j = indices[i];
    9166              :             fprintf (stderr, "%-32s %6" PRIu64 "%c\n",
    9167              :                      get_tree_code_name ((enum tree_code) j),
    9168              :                      SIZE_AMOUNT (tree_code_counts[j]));
    9169              :           }
    9170              :         mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
    9171              :         fprintf (stderr, "\n");
    9172              :         ssanames_print_statistics ();
    9173              :         fprintf (stderr, "\n");
    9174              :         phinodes_print_statistics ();
    9175              :         fprintf (stderr, "\n");
    9176              :       }
    9177              :     }
    9178              :   else
    9179            0 :     fprintf (stderr, "(No per-node statistics)\n");
    9180              : 
    9181            0 :   print_type_hash_statistics ();
    9182            0 :   print_debug_expr_statistics ();
    9183            0 :   print_value_expr_statistics ();
    9184            0 :   lang_hooks.print_statistics ();
    9185            0 : }
    9186              : 
    9187              : #define FILE_FUNCTION_FORMAT "_GLOBAL__%s_%s"
    9188              : 
    9189              : /* Generate a crc32 of the low BYTES bytes of VALUE.  */
    9190              : 
    9191              : unsigned
    9192     17469657 : crc32_unsigned_n (unsigned chksum, unsigned value, unsigned bytes)
    9193              : {
    9194              :   /* This relies on the raw feedback's top 4 bits being zero.  */
    9195              : #define FEEDBACK(X) ((X) * 0x04c11db7)
    9196              : #define SYNDROME(X) (FEEDBACK ((X) & 1) ^ FEEDBACK ((X) & 2) \
    9197              :                      ^ FEEDBACK ((X) & 4) ^ FEEDBACK ((X) & 8))
    9198     17469657 :   static const unsigned syndromes[16] =
    9199              :     {
    9200              :       SYNDROME(0x0), SYNDROME(0x1), SYNDROME(0x2), SYNDROME(0x3),
    9201              :       SYNDROME(0x4), SYNDROME(0x5), SYNDROME(0x6), SYNDROME(0x7),
    9202              :       SYNDROME(0x8), SYNDROME(0x9), SYNDROME(0xa), SYNDROME(0xb),
    9203              :       SYNDROME(0xc), SYNDROME(0xd), SYNDROME(0xe), SYNDROME(0xf),
    9204              :     };
    9205              : #undef FEEDBACK
    9206              : #undef SYNDROME
    9207              : 
    9208     17469657 :   value <<= (32 - bytes * 8);
    9209     58244991 :   for (unsigned ix = bytes * 2; ix--; value <<= 4)
    9210              :     {
    9211     40775334 :       unsigned feedback = syndromes[((value ^ chksum) >> 28) & 0xf];
    9212              : 
    9213     40775334 :       chksum = (chksum << 4) ^ feedback;
    9214              :     }
    9215              : 
    9216     17469657 :   return chksum;
    9217              : }
    9218              : 
    9219              : /* Generate a crc32 of a string.  */
    9220              : 
    9221              : unsigned
    9222        10123 : crc32_string (unsigned chksum, const char *string)
    9223              : {
    9224       405324 :   do
    9225       405324 :     chksum = crc32_byte (chksum, *string);
    9226       405324 :   while (*string++);
    9227        10123 :   return chksum;
    9228              : }
    9229              : 
    9230              : /* P is a string that will be used in a symbol.  Mask out any characters
    9231              :    that are not valid in that context.  */
    9232              : 
    9233              : void
    9234         7513 : clean_symbol_name (char *p)
    9235              : {
    9236        83120 :   for (; *p; p++)
    9237        75607 :     if (! (ISALNUM (*p)
    9238              : #ifndef NO_DOLLAR_IN_LABEL      /* this for `$'; unlikely, but... -- kr */
    9239              :             || *p == '$'
    9240              : #endif
    9241              : #ifndef NO_DOT_IN_LABEL         /* this for `.'; unlikely, but...  */
    9242              :             || *p == '.'
    9243              : #endif
    9244              :            ))
    9245         6914 :       *p = '_';
    9246         7513 : }
    9247              : 
    9248              : static GTY(()) unsigned anon_cnt = 0; /* Saved for PCH.  */
    9249              : 
    9250              : /* Create a unique anonymous identifier.  The identifier is still a
    9251              :    valid assembly label.  */
    9252              : 
    9253              : tree
    9254      3605388 : make_anon_name ()
    9255              : {
    9256      3605388 :   const char *fmt =
    9257              : #if !defined (NO_DOT_IN_LABEL)
    9258              :     "."
    9259              : #elif !defined (NO_DOLLAR_IN_LABEL)
    9260              :     "$"
    9261              : #else
    9262              :     "_"
    9263              : #endif
    9264              :     "_anon_%d";
    9265              : 
    9266      3605388 :   char buf[24];
    9267      3605388 :   int len = snprintf (buf, sizeof (buf), fmt, anon_cnt++);
    9268      3605388 :   gcc_checking_assert (len < int (sizeof (buf)));
    9269              : 
    9270      3605388 :   tree id = get_identifier_with_length (buf, len);
    9271      3605388 :   IDENTIFIER_ANON_P (id) = true;
    9272              : 
    9273      3605388 :   return id;
    9274              : }
    9275              : 
    9276              : /* Generate a name for a special-purpose function.
    9277              :    The generated name may need to be unique across the whole link.
    9278              :    Changes to this function may also require corresponding changes to
    9279              :    xstrdup_mask_random.
    9280              :    TYPE is some string to identify the purpose of this function to the
    9281              :    linker or collect2; it must start with an uppercase letter,
    9282              :    one of:
    9283              :    I - for constructors
    9284              :    D - for destructors
    9285              :    N - for C++ anonymous namespaces
    9286              :    F - for DWARF unwind frame information.  */
    9287              : 
    9288              : tree
    9289         5627 : get_file_function_name (const char *type)
    9290              : {
    9291         5627 :   char *buf;
    9292         5627 :   const char *p;
    9293         5627 :   char *q;
    9294              : 
    9295              :   /* If we already have a name we know to be unique, just use that.  */
    9296         5627 :   if (first_global_object_name)
    9297         5328 :     p = q = ASTRDUP (first_global_object_name);
    9298              :   /* If the target is handling the constructors/destructors, they
    9299              :      will be local to this file and the name is only necessary for
    9300              :      debugging purposes.
    9301              :      We also assign sub_I and sub_D suffixes to constructors called from
    9302              :      the global static constructors.  These are always local.
    9303              :      OpenMP "declare target" offloaded constructors/destructors use "off_I" and
    9304              :      "off_D" for the same purpose.  */
    9305          299 :   else if (((type[0] == 'I' || type[0] == 'D') && targetm.have_ctors_dtors)
    9306          598 :            || ((startswith (type, "sub_") || startswith (type, "off_"))
    9307          299 :                && (type[4] == 'I' || type[4] == 'D')))
    9308              :     {
    9309          299 :       const char *file = main_input_filename;
    9310          299 :       if (! file)
    9311            0 :         file = LOCATION_FILE (input_location);
    9312              :       /* Just use the file's basename, because the full pathname
    9313              :          might be quite long.  */
    9314          299 :       p = q = ASTRDUP (lbasename (file));
    9315              :     }
    9316              :   else
    9317              :     {
    9318              :       /* Otherwise, the name must be unique across the entire link.
    9319              :          We don't have anything that we know to be unique to this translation
    9320              :          unit, so use what we do have and throw in some randomness.  */
    9321            0 :       unsigned len;
    9322            0 :       const char *name = weak_global_object_name;
    9323            0 :       const char *file = main_input_filename;
    9324              : 
    9325            0 :       if (! name)
    9326            0 :         name = "";
    9327            0 :       if (! file)
    9328            0 :         file = LOCATION_FILE (input_location);
    9329              : 
    9330            0 :       len = strlen (file);
    9331            0 :       q = (char *) alloca (9 + 19 + len + 1);
    9332            0 :       memcpy (q, file, len + 1);
    9333              : 
    9334            0 :       snprintf (q + len, 9 + 19 + 1, "_%08X_" HOST_WIDE_INT_PRINT_HEX,
    9335              :                 crc32_string (0, name), get_random_seed (false));
    9336              : 
    9337            0 :       p = q;
    9338              :     }
    9339              : 
    9340         5627 :   clean_symbol_name (q);
    9341         5627 :   buf = (char *) alloca (sizeof (FILE_FUNCTION_FORMAT) + strlen (p)
    9342              :                          + strlen (type));
    9343              : 
    9344              :   /* Set up the name of the file-level functions we may need.
    9345              :      Use a global object (which is already required to be unique over
    9346              :      the program) rather than the file name (which imposes extra
    9347              :      constraints).  */
    9348         5627 :   sprintf (buf, FILE_FUNCTION_FORMAT, type, p);
    9349              : 
    9350         5627 :   return get_identifier (buf);
    9351              : }
    9352              : 
    9353              : #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
    9354              : 
    9355              : /* Complain that the tree code of NODE does not match the expected 0
    9356              :    terminated list of trailing codes.  The trailing code list can be
    9357              :    empty, for a more vague error message.  FILE, LINE, and FUNCTION
    9358              :    are of the caller.  */
    9359              : 
    9360              : void
    9361            2 : tree_check_failed (const_tree node, const char *file,
    9362              :                    int line, const char *function, ...)
    9363              : {
    9364            2 :   va_list args;
    9365            2 :   const char *buffer;
    9366            2 :   unsigned length = 0;
    9367            2 :   enum tree_code code;
    9368              : 
    9369            2 :   va_start (args, function);
    9370            4 :   while ((code = (enum tree_code) va_arg (args, int)))
    9371            2 :     length += 4 + strlen (get_tree_code_name (code));
    9372            2 :   va_end (args);
    9373            2 :   if (length)
    9374              :     {
    9375            2 :       char *tmp;
    9376            2 :       va_start (args, function);
    9377            2 :       length += strlen ("expected ");
    9378            2 :       buffer = tmp = (char *) alloca (length);
    9379            2 :       length = 0;
    9380            4 :       while ((code = (enum tree_code) va_arg (args, int)))
    9381              :         {
    9382            2 :           const char *prefix = length ? " or " : "expected ";
    9383              : 
    9384            2 :           strcpy (tmp + length, prefix);
    9385            2 :           length += strlen (prefix);
    9386            2 :           strcpy (tmp + length, get_tree_code_name (code));
    9387            2 :           length += strlen (get_tree_code_name (code));
    9388              :         }
    9389            2 :       va_end (args);
    9390              :     }
    9391              :   else
    9392              :     buffer = "unexpected node";
    9393              : 
    9394            2 :   internal_error ("tree check: %s, have %s in %s, at %s:%d",
    9395            2 :                   buffer, get_tree_code_name (TREE_CODE (node)),
    9396              :                   function, trim_filename (file), line);
    9397              : }
    9398              : 
    9399              : /* Complain that the tree code of NODE does match the expected 0
    9400              :    terminated list of trailing codes. FILE, LINE, and FUNCTION are of
    9401              :    the caller.  */
    9402              : 
    9403              : void
    9404            0 : tree_not_check_failed (const_tree node, const char *file,
    9405              :                        int line, const char *function, ...)
    9406              : {
    9407            0 :   va_list args;
    9408            0 :   char *buffer;
    9409            0 :   unsigned length = 0;
    9410            0 :   enum tree_code code;
    9411              : 
    9412            0 :   va_start (args, function);
    9413            0 :   while ((code = (enum tree_code) va_arg (args, int)))
    9414            0 :     length += 4 + strlen (get_tree_code_name (code));
    9415            0 :   va_end (args);
    9416            0 :   va_start (args, function);
    9417            0 :   buffer = (char *) alloca (length);
    9418            0 :   length = 0;
    9419            0 :   while ((code = (enum tree_code) va_arg (args, int)))
    9420              :     {
    9421            0 :       if (length)
    9422              :         {
    9423            0 :           strcpy (buffer + length, " or ");
    9424            0 :           length += 4;
    9425              :         }
    9426            0 :       strcpy (buffer + length, get_tree_code_name (code));
    9427            0 :       length += strlen (get_tree_code_name (code));
    9428              :     }
    9429            0 :   va_end (args);
    9430              : 
    9431            0 :   internal_error ("tree check: expected none of %s, have %s in %s, at %s:%d",
    9432            0 :                   buffer, get_tree_code_name (TREE_CODE (node)),
    9433              :                   function, trim_filename (file), line);
    9434              : }
    9435              : 
    9436              : /* Similar to tree_check_failed, except that we check for a class of tree
    9437              :    code, given in CL.  */
    9438              : 
    9439              : void
    9440            0 : tree_class_check_failed (const_tree node, const enum tree_code_class cl,
    9441              :                          const char *file, int line, const char *function)
    9442              : {
    9443            0 :   internal_error
    9444            0 :     ("tree check: expected class %qs, have %qs (%s) in %s, at %s:%d",
    9445            0 :      TREE_CODE_CLASS_STRING (cl),
    9446            0 :      TREE_CODE_CLASS_STRING (TREE_CODE_CLASS (TREE_CODE (node))),
    9447            0 :      get_tree_code_name (TREE_CODE (node)), function, trim_filename (file), line);
    9448              : }
    9449              : 
    9450              : /* Similar to tree_check_failed, except that instead of specifying a
    9451              :    dozen codes, use the knowledge that they're all sequential.  */
    9452              : 
    9453              : void
    9454            0 : tree_range_check_failed (const_tree node, const char *file, int line,
    9455              :                          const char *function, enum tree_code c1,
    9456              :                          enum tree_code c2)
    9457              : {
    9458            0 :   char *buffer;
    9459            0 :   unsigned length = 0;
    9460            0 :   unsigned int c;
    9461              : 
    9462            0 :   for (c = c1; c <= c2; ++c)
    9463            0 :     length += 4 + strlen (get_tree_code_name ((enum tree_code) c));
    9464              : 
    9465            0 :   length += strlen ("expected ");
    9466            0 :   buffer = (char *) alloca (length);
    9467            0 :   length = 0;
    9468              : 
    9469            0 :   for (c = c1; c <= c2; ++c)
    9470              :     {
    9471            0 :       const char *prefix = length ? " or " : "expected ";
    9472              : 
    9473            0 :       strcpy (buffer + length, prefix);
    9474            0 :       length += strlen (prefix);
    9475            0 :       strcpy (buffer + length, get_tree_code_name ((enum tree_code) c));
    9476            0 :       length += strlen (get_tree_code_name ((enum tree_code) c));
    9477              :     }
    9478              : 
    9479            0 :   internal_error ("tree check: %s, have %s in %s, at %s:%d",
    9480            0 :                   buffer, get_tree_code_name (TREE_CODE (node)),
    9481              :                   function, trim_filename (file), line);
    9482              : }
    9483              : 
    9484              : 
    9485              : /* Similar to tree_check_failed, except that we check that a tree does
    9486              :    not have the specified code, given in CL.  */
    9487              : 
    9488              : void
    9489            0 : tree_not_class_check_failed (const_tree node, const enum tree_code_class cl,
    9490              :                              const char *file, int line, const char *function)
    9491              : {
    9492            0 :   internal_error
    9493            0 :     ("tree check: did not expect class %qs, have %qs (%s) in %s, at %s:%d",
    9494            0 :      TREE_CODE_CLASS_STRING (cl),
    9495            0 :      TREE_CODE_CLASS_STRING (TREE_CODE_CLASS (TREE_CODE (node))),
    9496            0 :      get_tree_code_name (TREE_CODE (node)), function, trim_filename (file), line);
    9497              : }
    9498              : 
    9499              : 
    9500              : /* Similar to tree_check_failed but applied to OMP_CLAUSE codes.  */
    9501              : 
    9502              : void
    9503            0 : omp_clause_check_failed (const_tree node, const char *file, int line,
    9504              :                          const char *function, enum omp_clause_code code)
    9505              : {
    9506            0 :   internal_error ("tree check: expected %<omp_clause %s%>, have %qs "
    9507              :                   "in %s, at %s:%d",
    9508            0 :                   omp_clause_code_name[code],
    9509            0 :                   get_tree_code_name (TREE_CODE (node)),
    9510              :                   function, trim_filename (file), line);
    9511              : }
    9512              : 
    9513              : 
    9514              : /* Similar to tree_range_check_failed but applied to OMP_CLAUSE codes.  */
    9515              : 
    9516              : void
    9517            0 : omp_clause_range_check_failed (const_tree node, const char *file, int line,
    9518              :                                const char *function, enum omp_clause_code c1,
    9519              :                                enum omp_clause_code c2)
    9520              : {
    9521            0 :   char *buffer;
    9522            0 :   unsigned length = 0;
    9523            0 :   unsigned int c;
    9524              : 
    9525            0 :   for (c = c1; c <= c2; ++c)
    9526            0 :     length += 4 + strlen (omp_clause_code_name[c]);
    9527              : 
    9528            0 :   length += strlen ("expected ");
    9529            0 :   buffer = (char *) alloca (length);
    9530            0 :   length = 0;
    9531              : 
    9532            0 :   for (c = c1; c <= c2; ++c)
    9533              :     {
    9534            0 :       const char *prefix = length ? " or " : "expected ";
    9535              : 
    9536            0 :       strcpy (buffer + length, prefix);
    9537            0 :       length += strlen (prefix);
    9538            0 :       strcpy (buffer + length, omp_clause_code_name[c]);
    9539            0 :       length += strlen (omp_clause_code_name[c]);
    9540              :     }
    9541              : 
    9542            0 :   internal_error ("tree check: %s, have %s in %s, at %s:%d",
    9543            0 :                   buffer, omp_clause_code_name[TREE_CODE (node)],
    9544              :                   function, trim_filename (file), line);
    9545              : }
    9546              : 
    9547              : 
    9548              : #undef DEFTREESTRUCT
    9549              : #define DEFTREESTRUCT(VAL, NAME) NAME,
    9550              : 
    9551              : static const char *ts_enum_names[] = {
    9552              : #include "treestruct.def"
    9553              : };
    9554              : #undef DEFTREESTRUCT
    9555              : 
    9556              : #define TS_ENUM_NAME(EN) (ts_enum_names[(EN)])
    9557              : 
    9558              : /* Similar to tree_class_check_failed, except that we check for
    9559              :    whether CODE contains the tree structure identified by EN.  */
    9560              : 
    9561              : void
    9562            0 : tree_contains_struct_check_failed (const_tree node,
    9563              :                                    const enum tree_node_structure_enum en,
    9564              :                                    const char *file, int line,
    9565              :                                    const char *function)
    9566              : {
    9567            0 :   internal_error
    9568            0 :     ("tree check: expected tree that contains %qs structure, have %qs in %s, at %s:%d",
    9569            0 :      TS_ENUM_NAME (en),
    9570            0 :      get_tree_code_name (TREE_CODE (node)), function, trim_filename (file), line);
    9571              : }
    9572              : 
    9573              : 
    9574              : /* Similar to above, except that the check is for the bounds of a TREE_VEC's
    9575              :    (dynamically sized) vector.  */
    9576              : 
    9577              : void
    9578            0 : tree_int_cst_elt_check_failed (int idx, int len, const char *file, int line,
    9579              :                                const char *function)
    9580              : {
    9581            0 :   internal_error
    9582            0 :     ("tree check: accessed elt %d of %<tree_int_cst%> with %d elts in %s, "
    9583              :      "at %s:%d",
    9584              :      idx + 1, len, function, trim_filename (file), line);
    9585              : }
    9586              : 
    9587              : /* Similar to above, except that the check is for the bounds of a TREE_VEC's
    9588              :    (dynamically sized) vector.  */
    9589              : 
    9590              : void
    9591            0 : tree_vec_elt_check_failed (int idx, int len, const char *file, int line,
    9592              :                            const char *function)
    9593              : {
    9594            0 :   internal_error
    9595            0 :     ("tree check: accessed elt %d of %<tree_vec%> with %d elts in %s, at %s:%d",
    9596              :      idx + 1, len, function, trim_filename (file), line);
    9597              : }
    9598              : 
    9599              : /* Similar to above, except that the check is for the bounds of the operand
    9600              :    vector of an expression node EXP.  */
    9601              : 
    9602              : void
    9603            0 : tree_operand_check_failed (int idx, const_tree exp, const char *file,
    9604              :                            int line, const char *function)
    9605              : {
    9606            0 :   enum tree_code code = TREE_CODE (exp);
    9607            0 :   internal_error
    9608            0 :     ("tree check: accessed operand %d of %s with %d operands in %s, at %s:%d",
    9609              :      idx + 1, get_tree_code_name (code), TREE_OPERAND_LENGTH (exp),
    9610              :      function, trim_filename (file), line);
    9611              : }
    9612              : 
    9613              : /* Similar to above, except that the check is for the number of
    9614              :    operands of an OMP_CLAUSE node.  */
    9615              : 
    9616              : void
    9617            0 : omp_clause_operand_check_failed (int idx, const_tree t, const char *file,
    9618              :                                  int line, const char *function)
    9619              : {
    9620            0 :   internal_error
    9621            0 :     ("tree check: accessed operand %d of %<omp_clause %s%> with %d operands "
    9622            0 :      "in %s, at %s:%d", idx + 1, omp_clause_code_name[OMP_CLAUSE_CODE (t)],
    9623            0 :      omp_clause_num_ops [OMP_CLAUSE_CODE (t)], function,
    9624              :      trim_filename (file), line);
    9625              : }
    9626              : #endif /* ENABLE_TREE_CHECKING */
    9627              : 
    9628              : /* Create a new vector type node holding NUNITS units of type INNERTYPE,
    9629              :    and mapped to the machine mode MODE.  Initialize its fields and build
    9630              :    the information necessary for debugging output.  */
    9631              : 
    9632              : static tree
    9633     71776201 : make_vector_type (tree innertype, poly_int64 nunits, machine_mode mode)
    9634              : {
    9635     71776201 :   tree t;
    9636     71776201 :   tree mv_innertype = TYPE_MAIN_VARIANT (innertype);
    9637              : 
    9638     71776201 :   t = make_node (VECTOR_TYPE);
    9639     71776201 :   TREE_TYPE (t) = mv_innertype;
    9640     71776201 :   SET_TYPE_VECTOR_SUBPARTS (t, nunits);
    9641     71776201 :   SET_TYPE_MODE (t, mode);
    9642              : 
    9643     71776201 :   if (TYPE_STRUCTURAL_EQUALITY_P (mv_innertype) || in_lto_p)
    9644      1210848 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    9645     70565353 :   else if ((TYPE_CANONICAL (mv_innertype) != innertype
    9646     66905872 :             || mode != VOIDmode)
    9647    101940017 :            && !VECTOR_BOOLEAN_TYPE_P (t))
    9648     32453914 :     TYPE_CANONICAL (t)
    9649     64907828 :       = make_vector_type (TYPE_CANONICAL (mv_innertype), nunits, VOIDmode);
    9650              : 
    9651     71776201 :   layout_type (t);
    9652              : 
    9653     71776201 :   hashval_t hash = type_hash_canon_hash (t);
    9654     71776201 :   t = type_hash_canon (hash, t);
    9655              : 
    9656              :   /* We have built a main variant, based on the main variant of the
    9657              :      inner type. Use it to build the variant we return.  */
    9658    143546755 :   if ((TYPE_ATTRIBUTES (innertype) || TYPE_QUALS (innertype))
    9659     72652259 :       && TREE_TYPE (t) != innertype)
    9660       880391 :     return build_type_attribute_qual_variant (t,
    9661       880391 :                                               TYPE_ATTRIBUTES (innertype),
    9662       880391 :                                               TYPE_QUALS (innertype));
    9663              : 
    9664              :   return t;
    9665              : }
    9666              : 
    9667              : static tree
    9668      4149166 : make_or_reuse_type (unsigned size, int unsignedp)
    9669              : {
    9670      4149166 :   int i;
    9671              : 
    9672      4149166 :   if (size == INT_TYPE_SIZE)
    9673       890637 :     return unsignedp ? unsigned_type_node : integer_type_node;
    9674      3258529 :   if (size == CHAR_TYPE_SIZE)
    9675       593758 :     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
    9676      2664771 :   if (size == SHORT_TYPE_SIZE)
    9677       890637 :     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
    9678      1810410 :   if (size == LONG_TYPE_SIZE)
    9679       868929 :     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
    9680       905205 :   if (size == LONG_LONG_TYPE_SIZE)
    9681        21708 :     return (unsignedp ? long_long_unsigned_type_node
    9682        21708 :             : long_long_integer_type_node);
    9683              : 
    9684       897777 :   for (i = 0; i < NUM_INT_N_ENTS; i ++)
    9685       883497 :     if (size == int_n_data[i].bitsize
    9686       883497 :         && int_n_enabled_p[i])
    9687       869217 :       return (unsignedp ? int_n_trees[i].unsigned_type
    9688       869217 :               : int_n_trees[i].signed_type);
    9689              : 
    9690        14280 :   if (unsignedp)
    9691         7140 :     return make_unsigned_type (size);
    9692              :   else
    9693         7140 :     return make_signed_type (size);
    9694              : }
    9695              : 
    9696              : /* Create or reuse a fract type by SIZE, UNSIGNEDP, and SATP.  */
    9697              : 
    9698              : static tree
    9699      5937580 : make_or_reuse_fract_type (unsigned size, int unsignedp, int satp)
    9700              : {
    9701      5937580 :   if (satp)
    9702              :     {
    9703      2968790 :       if (size == SHORT_FRACT_TYPE_SIZE)
    9704       593758 :         return unsignedp ? sat_unsigned_short_fract_type_node
    9705       593758 :                          : sat_short_fract_type_node;
    9706      2375032 :       if (size == FRACT_TYPE_SIZE)
    9707       593758 :         return unsignedp ? sat_unsigned_fract_type_node : sat_fract_type_node;
    9708      1781274 :       if (size == LONG_FRACT_TYPE_SIZE)
    9709       593758 :         return unsignedp ? sat_unsigned_long_fract_type_node
    9710       593758 :                          : sat_long_fract_type_node;
    9711      1187516 :       if (size == LONG_LONG_FRACT_TYPE_SIZE)
    9712       593758 :         return unsignedp ? sat_unsigned_long_long_fract_type_node
    9713       593758 :                          : sat_long_long_fract_type_node;
    9714              :     }
    9715              :   else
    9716              :     {
    9717      2968790 :       if (size == SHORT_FRACT_TYPE_SIZE)
    9718       593758 :         return unsignedp ? unsigned_short_fract_type_node
    9719       593758 :                          : short_fract_type_node;
    9720      2375032 :       if (size == FRACT_TYPE_SIZE)
    9721       593758 :         return unsignedp ? unsigned_fract_type_node : fract_type_node;
    9722      1781274 :       if (size == LONG_FRACT_TYPE_SIZE)
    9723       593758 :         return unsignedp ? unsigned_long_fract_type_node
    9724       593758 :                          : long_fract_type_node;
    9725      1187516 :       if (size == LONG_LONG_FRACT_TYPE_SIZE)
    9726       593758 :         return unsignedp ? unsigned_long_long_fract_type_node
    9727       593758 :                          : long_long_fract_type_node;
    9728              :     }
    9729              : 
    9730      1187516 :   return make_fract_type (size, unsignedp, satp);
    9731              : }
    9732              : 
    9733              : /* Create or reuse an accum type by SIZE, UNSIGNEDP, and SATP.  */
    9734              : 
    9735              : static tree
    9736      4750064 : make_or_reuse_accum_type (unsigned size, int unsignedp, int satp)
    9737              : {
    9738      4750064 :   if (satp)
    9739              :     {
    9740      2375032 :       if (size == SHORT_ACCUM_TYPE_SIZE)
    9741       593758 :         return unsignedp ? sat_unsigned_short_accum_type_node
    9742       593758 :                          : sat_short_accum_type_node;
    9743      1781274 :       if (size == ACCUM_TYPE_SIZE)
    9744       593758 :         return unsignedp ? sat_unsigned_accum_type_node : sat_accum_type_node;
    9745      1187516 :       if (size == LONG_ACCUM_TYPE_SIZE)
    9746       593758 :         return unsignedp ? sat_unsigned_long_accum_type_node
    9747       593758 :                          : sat_long_accum_type_node;
    9748       593758 :       if (size == LONG_LONG_ACCUM_TYPE_SIZE)
    9749       593758 :         return unsignedp ? sat_unsigned_long_long_accum_type_node
    9750       593758 :                          : sat_long_long_accum_type_node;
    9751              :     }
    9752              :   else
    9753              :     {
    9754      2375032 :       if (size == SHORT_ACCUM_TYPE_SIZE)
    9755       593758 :         return unsignedp ? unsigned_short_accum_type_node
    9756       593758 :                          : short_accum_type_node;
    9757      1781274 :       if (size == ACCUM_TYPE_SIZE)
    9758       593758 :         return unsignedp ? unsigned_accum_type_node : accum_type_node;
    9759      1187516 :       if (size == LONG_ACCUM_TYPE_SIZE)
    9760       593758 :         return unsignedp ? unsigned_long_accum_type_node
    9761       593758 :                          : long_accum_type_node;
    9762       593758 :       if (size == LONG_LONG_ACCUM_TYPE_SIZE)
    9763       593758 :         return unsignedp ? unsigned_long_long_accum_type_node
    9764       593758 :                          : long_long_accum_type_node;
    9765              :     }
    9766              : 
    9767            0 :   return make_accum_type (size, unsignedp, satp);
    9768              : }
    9769              : 
    9770              : 
    9771              : /* Create an atomic variant node for TYPE.  This routine is called
    9772              :    during initialization of data types to create the 5 basic atomic
    9773              :    types.  The generic build_variant_type function requires these to
    9774              :    already be set up in order to function properly, so cannot be
    9775              :    called from there.  If ALIGN is non-zero, then ensure alignment is
    9776              :    overridden to this value.  */
    9777              : 
    9778              : static tree
    9779      1484395 : build_atomic_base (tree type, unsigned int align)
    9780              : {
    9781      1484395 :   tree t;
    9782              : 
    9783              :   /* Make sure its not already registered.  */
    9784      1484395 :   if ((t = get_qualified_type (type, TYPE_QUAL_ATOMIC)))
    9785              :     return t;
    9786              : 
    9787      1484395 :   t = build_variant_type_copy (type);
    9788      1484395 :   set_type_quals (t, TYPE_QUAL_ATOMIC);
    9789              : 
    9790      1484395 :   if (align)
    9791            0 :     SET_TYPE_ALIGN (t, align);
    9792              : 
    9793              :   return t;
    9794              : }
    9795              : 
    9796              : /* Return unsigned integer tree node for TYPE.  */
    9797              : 
    9798              : tree
    9799       296919 : unsigned_integer_tree_node_for_type (const char *type)
    9800              : {
    9801       296919 :   tree type_node;
    9802              : 
    9803       296919 :   if (strcmp (type, "unsigned int") == 0)
    9804         7236 :     type_node = unsigned_type_node;
    9805       289683 :   else if (strcmp (type, "long unsigned int") == 0)
    9806       289683 :     type_node = long_unsigned_type_node;
    9807            0 :   else if (strcmp (type, "long long unsigned int") == 0)
    9808            0 :     type_node = long_long_unsigned_type_node;
    9809            0 :   else if (strcmp (type, "short unsigned int") == 0)
    9810            0 :     type_node = short_unsigned_type_node;
    9811              :   else
    9812              :     {
    9813              :       int i;
    9814              : 
    9815              :       type_node = nullptr;
    9816            0 :       for (i = 0; i < NUM_INT_N_ENTS; i++)
    9817            0 :         if (int_n_enabled_p[i])
    9818              :           {
    9819            0 :             char name[50], altname[50];
    9820            0 :             sprintf (name, "__int%d unsigned", int_n_data[i].bitsize);
    9821            0 :             sprintf (altname, "__int%d__ unsigned", int_n_data[i].bitsize);
    9822              : 
    9823            0 :             if (strcmp (name, type) == 0
    9824            0 :                 || strcmp (altname, type) == 0)
    9825              :               {
    9826            0 :                 type_node = int_n_trees[i].unsigned_type;
    9827              :               }
    9828              :           }
    9829            0 :       if (type_node == nullptr)
    9830            0 :         gcc_unreachable ();
    9831              :     }
    9832              : 
    9833       296919 :   return type_node;
    9834              : }
    9835              : 
    9836              : /* Information about the _FloatN and _FloatNx types.  This must be in
    9837              :    the same order as the corresponding TI_* enum values.  */
    9838              : const floatn_type_info floatn_nx_types[NUM_FLOATN_NX_TYPES] =
    9839              :   {
    9840              :     { 16, false },
    9841              :     { 32, false },
    9842              :     { 64, false },
    9843              :     { 128, false },
    9844              :     { 32, true },
    9845              :     { 64, true },
    9846              :     { 128, true },
    9847              :   };
    9848              : 
    9849              : 
    9850              : /* Create nodes for all integer types (and error_mark_node) using the sizes
    9851              :    of C datatypes.  SIGNED_CHAR specifies whether char is signed.  */
    9852              : 
    9853              : void
    9854       296879 : build_common_tree_nodes (bool signed_char)
    9855              : {
    9856       296879 :   int i;
    9857              : 
    9858       296879 :   error_mark_node = make_node (ERROR_MARK);
    9859       296879 :   TREE_TYPE (error_mark_node) = error_mark_node;
    9860              : 
    9861       296879 :   initialize_sizetypes ();
    9862              : 
    9863              :   /* Define both `signed char' and `unsigned char'.  */
    9864       296879 :   signed_char_type_node = make_signed_type (CHAR_TYPE_SIZE);
    9865       296879 :   TYPE_STRING_FLAG (signed_char_type_node) = 1;
    9866       296879 :   unsigned_char_type_node = make_unsigned_type (CHAR_TYPE_SIZE);
    9867       296879 :   TYPE_STRING_FLAG (unsigned_char_type_node) = 1;
    9868              : 
    9869              :   /* Define `char', which is like either `signed char' or `unsigned char'
    9870              :      but not the same as either.  */
    9871       296879 :   char_type_node
    9872       296879 :     = (signed_char
    9873       296879 :        ? make_signed_type (CHAR_TYPE_SIZE)
    9874        58840 :        : make_unsigned_type (CHAR_TYPE_SIZE));
    9875       296879 :   TYPE_STRING_FLAG (char_type_node) = 1;
    9876              : 
    9877       296879 :   short_integer_type_node = make_signed_type (SHORT_TYPE_SIZE);
    9878       296879 :   short_unsigned_type_node = make_unsigned_type (SHORT_TYPE_SIZE);
    9879       296879 :   integer_type_node = make_signed_type (INT_TYPE_SIZE);
    9880       296879 :   unsigned_type_node = make_unsigned_type (INT_TYPE_SIZE);
    9881       304115 :   long_integer_type_node = make_signed_type (LONG_TYPE_SIZE);
    9882       304115 :   long_unsigned_type_node = make_unsigned_type (LONG_TYPE_SIZE);
    9883       296879 :   long_long_integer_type_node = make_signed_type (LONG_LONG_TYPE_SIZE);
    9884       296879 :   long_long_unsigned_type_node = make_unsigned_type (LONG_LONG_TYPE_SIZE);
    9885              : 
    9886       593758 :   for (i = 0; i < NUM_INT_N_ENTS; i ++)
    9887              :     {
    9888       296879 :       int_n_trees[i].signed_type = make_signed_type (int_n_data[i].bitsize);
    9889       296879 :       int_n_trees[i].unsigned_type = make_unsigned_type (int_n_data[i].bitsize);
    9890              : 
    9891       296879 :       if (int_n_enabled_p[i])
    9892              :         {
    9893       289739 :           integer_types[itk_intN_0 + i * 2] = int_n_trees[i].signed_type;
    9894       289739 :           integer_types[itk_unsigned_intN_0 + i * 2] = int_n_trees[i].unsigned_type;
    9895              :         }
    9896              :     }
    9897              : 
    9898              :   /* Define a boolean type.  This type only represents boolean values but
    9899              :      may be larger than char depending on the value of BOOL_TYPE_SIZE.  */
    9900       296879 :   boolean_type_node = make_unsigned_type (BOOL_TYPE_SIZE);
    9901       296879 :   TREE_SET_CODE (boolean_type_node, BOOLEAN_TYPE);
    9902       296879 :   TYPE_PRECISION (boolean_type_node) = 1;
    9903       296879 :   TYPE_MAX_VALUE (boolean_type_node) = build_int_cst (boolean_type_node, 1);
    9904              : 
    9905              :   /* Define what type to use for size_t.  */
    9906       304115 :   size_type_node = unsigned_integer_tree_node_for_type (SIZE_TYPE);
    9907              : 
    9908              :   /* Define what type to use for ptrdiff_t.  */
    9909       304115 :   if (strcmp (PTRDIFF_TYPE, "int") == 0)
    9910         7236 :     ptrdiff_type_node = integer_type_node;
    9911       289643 :   else if (strcmp (PTRDIFF_TYPE, "long int") == 0)
    9912       289643 :     ptrdiff_type_node = long_integer_type_node;
    9913            0 :   else if (strcmp (PTRDIFF_TYPE, "long long int") == 0)
    9914            0 :     ptrdiff_type_node = long_long_integer_type_node;
    9915            0 :   else if (strcmp (PTRDIFF_TYPE, "short int") == 0)
    9916            0 :     ptrdiff_type_node = short_integer_type_node;
    9917              :   else
    9918              :     {
    9919            0 :       ptrdiff_type_node = NULL_TREE;
    9920            0 :       for (int i = 0; i < NUM_INT_N_ENTS; i++)
    9921            0 :         if (int_n_enabled_p[i])
    9922              :           {
    9923            0 :             char name[50], altname[50];
    9924            0 :             sprintf (name, "__int%d", int_n_data[i].bitsize);
    9925            0 :             sprintf (altname, "__int%d__", int_n_data[i].bitsize);
    9926              : 
    9927            0 :             if (strcmp (name, PTRDIFF_TYPE) == 0
    9928            0 :                 || strcmp (altname, PTRDIFF_TYPE) == 0)
    9929            0 :               ptrdiff_type_node = int_n_trees[i].signed_type;
    9930              :           }
    9931            0 :       if (ptrdiff_type_node == NULL_TREE)
    9932            0 :         gcc_unreachable ();
    9933              :     }
    9934              : 
    9935              :   /* Fill in the rest of the sized types.  Reuse existing type nodes
    9936              :      when possible.  */
    9937       296879 :   intQI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (QImode), 0);
    9938       296879 :   intHI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (HImode), 0);
    9939       296879 :   intSI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (SImode), 0);
    9940       296879 :   intDI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (DImode), 0);
    9941       296879 :   intTI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (TImode), 0);
    9942              : 
    9943       296879 :   unsigned_intQI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (QImode), 1);
    9944       296879 :   unsigned_intHI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (HImode), 1);
    9945       296879 :   unsigned_intSI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (SImode), 1);
    9946       296879 :   unsigned_intDI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (DImode), 1);
    9947       296879 :   unsigned_intTI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (TImode), 1);
    9948              : 
    9949              :   /* Don't call build_qualified type for atomics.  That routine does
    9950              :      special processing for atomics, and until they are initialized
    9951              :      it's better not to make that call.
    9952              : 
    9953              :      Check to see if there is a target override for atomic types.  */
    9954              : 
    9955       296879 :   atomicQI_type_node = build_atomic_base (unsigned_intQI_type_node,
    9956       296879 :                                         targetm.atomic_align_for_mode (QImode));
    9957       296879 :   atomicHI_type_node = build_atomic_base (unsigned_intHI_type_node,
    9958       296879 :                                         targetm.atomic_align_for_mode (HImode));
    9959       296879 :   atomicSI_type_node = build_atomic_base (unsigned_intSI_type_node,
    9960       296879 :                                         targetm.atomic_align_for_mode (SImode));
    9961       296879 :   atomicDI_type_node = build_atomic_base (unsigned_intDI_type_node,
    9962       296879 :                                         targetm.atomic_align_for_mode (DImode));
    9963       296879 :   atomicTI_type_node = build_atomic_base (unsigned_intTI_type_node,
    9964       296879 :                                         targetm.atomic_align_for_mode (TImode));
    9965              : 
    9966       296879 :   access_public_node = get_identifier ("public");
    9967       296879 :   access_protected_node = get_identifier ("protected");
    9968       296879 :   access_private_node = get_identifier ("private");
    9969              : 
    9970              :   /* Define these next since types below may used them.  */
    9971       296879 :   integer_zero_node = build_int_cst (integer_type_node, 0);
    9972       296879 :   integer_one_node = build_int_cst (integer_type_node, 1);
    9973       296879 :   integer_minus_one_node = build_int_cst (integer_type_node, -1);
    9974              : 
    9975       296879 :   size_zero_node = size_int (0);
    9976       296879 :   size_one_node = size_int (1);
    9977       296879 :   bitsize_zero_node = bitsize_int (0);
    9978       296879 :   bitsize_one_node = bitsize_int (1);
    9979       296879 :   bitsize_unit_node = bitsize_int (BITS_PER_UNIT);
    9980              : 
    9981       296879 :   boolean_false_node = TYPE_MIN_VALUE (boolean_type_node);
    9982       296879 :   boolean_true_node = TYPE_MAX_VALUE (boolean_type_node);
    9983              : 
    9984       296879 :   void_type_node = make_node (VOID_TYPE);
    9985       296879 :   layout_type (void_type_node);
    9986              : 
    9987              :   /* We are not going to have real types in C with less than byte alignment,
    9988              :      so we might as well not have any types that claim to have it.  */
    9989       296879 :   SET_TYPE_ALIGN (void_type_node, BITS_PER_UNIT);
    9990       296879 :   TYPE_USER_ALIGN (void_type_node) = 0;
    9991              : 
    9992       296879 :   void_node = make_node (VOID_CST);
    9993       296879 :   TREE_TYPE (void_node) = void_type_node;
    9994              : 
    9995       296879 :   void_list_node = build_tree_list (NULL_TREE, void_type_node);
    9996              : 
    9997       296879 :   null_pointer_node = build_int_cst (build_pointer_type (void_type_node), 0);
    9998       296879 :   layout_type (TREE_TYPE (null_pointer_node));
    9999              : 
   10000       296879 :   ptr_type_node = build_pointer_type (void_type_node);
   10001       296879 :   const_ptr_type_node
   10002       296879 :     = build_pointer_type (build_type_variant (void_type_node, 1, 0));
   10003      2078153 :   for (unsigned i = 0; i < ARRAY_SIZE (builtin_structptr_types); ++i)
   10004      1781274 :     builtin_structptr_types[i].node = builtin_structptr_types[i].base;
   10005              : 
   10006       304115 :   pointer_sized_int_node = build_nonstandard_integer_type (POINTER_SIZE, 1);
   10007              : 
   10008       296879 :   float_type_node = make_node (REAL_TYPE);
   10009       296879 :   machine_mode float_type_mode
   10010       296879 :     = targetm.c.mode_for_floating_type (TI_FLOAT_TYPE);
   10011       296879 :   SET_TYPE_MODE (float_type_node, float_type_mode);
   10012       296879 :   TYPE_PRECISION (float_type_node)
   10013       296879 :     = GET_MODE_PRECISION (float_type_mode).to_constant ();
   10014       296879 :   layout_type (float_type_node);
   10015              : 
   10016       296879 :   double_type_node = make_node (REAL_TYPE);
   10017       296879 :   machine_mode double_type_mode
   10018       296879 :     = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
   10019       296879 :   SET_TYPE_MODE (double_type_node, double_type_mode);
   10020       296879 :   TYPE_PRECISION (double_type_node)
   10021       296879 :     = GET_MODE_PRECISION (double_type_mode).to_constant ();
   10022       296879 :   layout_type (double_type_node);
   10023              : 
   10024       296879 :   long_double_type_node = make_node (REAL_TYPE);
   10025       296879 :   machine_mode long_double_type_mode
   10026       296879 :     = targetm.c.mode_for_floating_type (TI_LONG_DOUBLE_TYPE);
   10027       296879 :   SET_TYPE_MODE (long_double_type_node, long_double_type_mode);
   10028       296879 :   TYPE_PRECISION (long_double_type_node)
   10029       296879 :     = GET_MODE_PRECISION (long_double_type_mode).to_constant ();
   10030       296879 :   layout_type (long_double_type_node);
   10031              : 
   10032      2671911 :   for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
   10033              :     {
   10034      2078153 :       int n = floatn_nx_types[i].n;
   10035      2078153 :       bool extended = floatn_nx_types[i].extended;
   10036      2078153 :       scalar_float_mode mode;
   10037      2078153 :       if (!targetm.floatn_mode (n, extended).exists (&mode))
   10038       296879 :         continue;
   10039      1781274 :       int precision = GET_MODE_PRECISION (mode);
   10040      1781274 :       FLOATN_NX_TYPE_NODE (i) = make_node (REAL_TYPE);
   10041      1781274 :       TYPE_PRECISION (FLOATN_NX_TYPE_NODE (i)) = precision;
   10042      1781274 :       layout_type (FLOATN_NX_TYPE_NODE (i));
   10043      1781274 :       SET_TYPE_MODE (FLOATN_NX_TYPE_NODE (i), mode);
   10044              :     }
   10045       296879 :   float128t_type_node = float128_type_node;
   10046              : #ifdef HAVE_BFmode
   10047       296879 :   if (REAL_MODE_FORMAT (BFmode) == &arm_bfloat_half_format
   10048       296879 :       && targetm.scalar_mode_supported_p (BFmode)
   10049       593758 :       && targetm.libgcc_floating_mode_supported_p (BFmode))
   10050              :     {
   10051       296879 :       bfloat16_type_node = make_node (REAL_TYPE);
   10052       296879 :       TYPE_PRECISION (bfloat16_type_node) = GET_MODE_PRECISION (BFmode);
   10053       296879 :       layout_type (bfloat16_type_node);
   10054       296879 :       SET_TYPE_MODE (bfloat16_type_node, BFmode);
   10055              :     }
   10056              : #endif
   10057              : 
   10058       296879 :   float_ptr_type_node = build_pointer_type (float_type_node);
   10059       296879 :   double_ptr_type_node = build_pointer_type (double_type_node);
   10060       296879 :   long_double_ptr_type_node = build_pointer_type (long_double_type_node);
   10061       296879 :   integer_ptr_type_node = build_pointer_type (integer_type_node);
   10062              : 
   10063              :   /* Fixed size integer types.  */
   10064       296879 :   uint16_type_node = make_or_reuse_type (16, 1);
   10065       296879 :   uint32_type_node = make_or_reuse_type (32, 1);
   10066       296879 :   uint64_type_node = make_or_reuse_type (64, 1);
   10067       296879 :   if (targetm.scalar_mode_supported_p (TImode))
   10068       289739 :     uint128_type_node = make_or_reuse_type (128, 1);
   10069              : 
   10070              :   /* Decimal float types. */
   10071       296879 :   if (targetm.decimal_float_supported_p ())
   10072              :     {
   10073       296879 :       dfloat32_type_node = make_node (REAL_TYPE);
   10074       296879 :       TYPE_PRECISION (dfloat32_type_node) = DECIMAL32_TYPE_SIZE;
   10075       296879 :       SET_TYPE_MODE (dfloat32_type_node, SDmode);
   10076       296879 :       layout_type (dfloat32_type_node);
   10077              : 
   10078       296879 :       dfloat64_type_node = make_node (REAL_TYPE);
   10079       296879 :       TYPE_PRECISION (dfloat64_type_node) = DECIMAL64_TYPE_SIZE;
   10080       296879 :       SET_TYPE_MODE (dfloat64_type_node, DDmode);
   10081       296879 :       layout_type (dfloat64_type_node);
   10082              : 
   10083       296879 :       dfloat128_type_node = make_node (REAL_TYPE);
   10084       296879 :       TYPE_PRECISION (dfloat128_type_node) = DECIMAL128_TYPE_SIZE;
   10085       296879 :       SET_TYPE_MODE (dfloat128_type_node, TDmode);
   10086       296879 :       layout_type (dfloat128_type_node);
   10087              : 
   10088       296879 :       dfloat64x_type_node = make_node (REAL_TYPE);
   10089       296879 :       TYPE_PRECISION (dfloat64x_type_node) = DECIMAL128_TYPE_SIZE;
   10090       296879 :       SET_TYPE_MODE (dfloat64x_type_node, TDmode);
   10091       296879 :       layout_type (dfloat64x_type_node);
   10092              :     }
   10093              : 
   10094       296879 :   complex_integer_type_node = build_complex_type (integer_type_node, true);
   10095       296879 :   complex_float_type_node = build_complex_type (float_type_node, true);
   10096       296879 :   complex_double_type_node = build_complex_type (double_type_node, true);
   10097       296879 :   complex_long_double_type_node = build_complex_type (long_double_type_node,
   10098              :                                                       true);
   10099              : 
   10100      2375032 :   for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
   10101              :     {
   10102      2078153 :       if (FLOATN_NX_TYPE_NODE (i) != NULL_TREE)
   10103      1781274 :         COMPLEX_FLOATN_NX_TYPE_NODE (i)
   10104      1781274 :           = build_complex_type (FLOATN_NX_TYPE_NODE (i));
   10105              :     }
   10106              : 
   10107              : /* Make fixed-point nodes based on sat/non-sat and signed/unsigned.  */
   10108              : #define MAKE_FIXED_TYPE_NODE(KIND,SIZE) \
   10109              :   sat_ ## KIND ## _type_node = \
   10110              :     make_sat_signed_ ## KIND ## _type (SIZE); \
   10111              :   sat_unsigned_ ## KIND ## _type_node = \
   10112              :     make_sat_unsigned_ ## KIND ## _type (SIZE); \
   10113              :   KIND ## _type_node = make_signed_ ## KIND ## _type (SIZE); \
   10114              :   unsigned_ ## KIND ## _type_node = \
   10115              :     make_unsigned_ ## KIND ## _type (SIZE);
   10116              : 
   10117              : #define MAKE_FIXED_TYPE_NODE_WIDTH(KIND,WIDTH,SIZE) \
   10118              :   sat_ ## WIDTH ## KIND ## _type_node = \
   10119              :     make_sat_signed_ ## KIND ## _type (SIZE); \
   10120              :   sat_unsigned_ ## WIDTH ## KIND ## _type_node = \
   10121              :     make_sat_unsigned_ ## KIND ## _type (SIZE); \
   10122              :   WIDTH ## KIND ## _type_node = make_signed_ ## KIND ## _type (SIZE); \
   10123              :   unsigned_ ## WIDTH ## KIND ## _type_node = \
   10124              :     make_unsigned_ ## KIND ## _type (SIZE);
   10125              : 
   10126              : /* Make fixed-point type nodes based on four different widths.  */
   10127              : #define MAKE_FIXED_TYPE_NODE_FAMILY(N1,N2) \
   10128              :   MAKE_FIXED_TYPE_NODE_WIDTH (N1, short_, SHORT_ ## N2 ## _TYPE_SIZE) \
   10129              :   MAKE_FIXED_TYPE_NODE (N1, N2 ## _TYPE_SIZE) \
   10130              :   MAKE_FIXED_TYPE_NODE_WIDTH (N1, long_, LONG_ ## N2 ## _TYPE_SIZE) \
   10131              :   MAKE_FIXED_TYPE_NODE_WIDTH (N1, long_long_, LONG_LONG_ ## N2 ## _TYPE_SIZE)
   10132              : 
   10133              : /* Make fixed-point mode nodes based on sat/non-sat and signed/unsigned.  */
   10134              : #define MAKE_FIXED_MODE_NODE(KIND,NAME,MODE) \
   10135              :   NAME ## _type_node = \
   10136              :     make_or_reuse_signed_ ## KIND ## _type (GET_MODE_BITSIZE (MODE ## mode)); \
   10137              :   u ## NAME ## _type_node = \
   10138              :     make_or_reuse_unsigned_ ## KIND ## _type \
   10139              :       (GET_MODE_BITSIZE (U ## MODE ## mode)); \
   10140              :   sat_ ## NAME ## _type_node = \
   10141              :     make_or_reuse_sat_signed_ ## KIND ## _type \
   10142              :       (GET_MODE_BITSIZE (MODE ## mode)); \
   10143              :   sat_u ## NAME ## _type_node = \
   10144              :     make_or_reuse_sat_unsigned_ ## KIND ## _type \
   10145              :       (GET_MODE_BITSIZE (U ## MODE ## mode));
   10146              : 
   10147              :   /* Fixed-point type and mode nodes.  */
   10148       296879 :   MAKE_FIXED_TYPE_NODE_FAMILY (fract, FRACT)
   10149       296879 :   MAKE_FIXED_TYPE_NODE_FAMILY (accum, ACCUM)
   10150       296879 :   MAKE_FIXED_MODE_NODE (fract, qq, QQ)
   10151       296879 :   MAKE_FIXED_MODE_NODE (fract, hq, HQ)
   10152       296879 :   MAKE_FIXED_MODE_NODE (fract, sq, SQ)
   10153       296879 :   MAKE_FIXED_MODE_NODE (fract, dq, DQ)
   10154       296879 :   MAKE_FIXED_MODE_NODE (fract, tq, TQ)
   10155       296879 :   MAKE_FIXED_MODE_NODE (accum, ha, HA)
   10156       296879 :   MAKE_FIXED_MODE_NODE (accum, sa, SA)
   10157       296879 :   MAKE_FIXED_MODE_NODE (accum, da, DA)
   10158       296879 :   MAKE_FIXED_MODE_NODE (accum, ta, TA)
   10159              : 
   10160       296879 :   {
   10161       296879 :     tree t = targetm.build_builtin_va_list ();
   10162              : 
   10163              :     /* Many back-ends define record types without setting TYPE_NAME.
   10164              :        If we copied the record type here, we'd keep the original
   10165              :        record type without a name.  This breaks name mangling.  So,
   10166              :        don't copy record types and let c_common_nodes_and_builtins()
   10167              :        declare the type to be __builtin_va_list.  */
   10168       296879 :     if (TREE_CODE (t) != RECORD_TYPE)
   10169       296879 :       t = build_variant_type_copy (t);
   10170              : 
   10171       296879 :     va_list_type_node = t;
   10172              :   }
   10173              : 
   10174              :   /* SCEV analyzer global shared trees.  */
   10175       296879 :   chrec_dont_know = make_node (SCEV_NOT_KNOWN);
   10176       296879 :   TREE_TYPE (chrec_dont_know) = void_type_node;
   10177       296879 :   chrec_known = make_node (SCEV_KNOWN);
   10178       296879 :   TREE_TYPE (chrec_known) = void_type_node;
   10179       296879 : }
   10180              : 
   10181              : /* Modify DECL for given flags.
   10182              :    TM_PURE attribute is set only on types, so the function will modify
   10183              :    DECL's type when ECF_TM_PURE is used.  */
   10184              : 
   10185              : void
   10186     33402917 : set_call_expr_flags (tree decl, int flags)
   10187              : {
   10188     33402917 :   if (flags & ECF_NOTHROW)
   10189     29017258 :     TREE_NOTHROW (decl) = 1;
   10190     33402917 :   if (flags & ECF_CONST)
   10191     13710738 :     TREE_READONLY (decl) = 1;
   10192     33402917 :   if (flags & ECF_PURE)
   10193      1603610 :     DECL_PURE_P (decl) = 1;
   10194     33402917 :   if (flags & ECF_LOOPING_CONST_OR_PURE)
   10195        54731 :     DECL_LOOPING_CONST_OR_PURE_P (decl) = 1;
   10196     33402917 :   if (flags & ECF_NOVOPS)
   10197            0 :     DECL_IS_NOVOPS (decl) = 1;
   10198     33402917 :   if (flags & ECF_NORETURN)
   10199      1252224 :     TREE_THIS_VOLATILE (decl) = 1;
   10200     33402917 :   if (flags & ECF_MALLOC)
   10201       760170 :     DECL_IS_MALLOC (decl) = 1;
   10202     33402917 :   if (flags & ECF_RETURNS_TWICE)
   10203            0 :     DECL_IS_RETURNS_TWICE (decl) = 1;
   10204     33402917 :   if (flags & ECF_LEAF)
   10205     28847500 :     DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("leaf"),
   10206     28847500 :                                         NULL, DECL_ATTRIBUTES (decl));
   10207     33402917 :   if (flags & ECF_COLD)
   10208       653287 :     DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("cold"),
   10209       653287 :                                         NULL, DECL_ATTRIBUTES (decl));
   10210     33402917 :   if (flags & ECF_RET1)
   10211            0 :     DECL_ATTRIBUTES (decl)
   10212            0 :       = tree_cons (get_identifier ("fn spec"),
   10213              :                    build_tree_list (NULL_TREE, build_string (2, "1 ")),
   10214            0 :                    DECL_ATTRIBUTES (decl));
   10215     33402917 :   if ((flags & ECF_TM_PURE) && flag_tm)
   10216          537 :     apply_tm_attr (decl, get_identifier ("transaction_pure"));
   10217     33402917 :   if ((flags & ECF_XTHROW))
   10218       426146 :     DECL_ATTRIBUTES (decl)
   10219       852292 :       = tree_cons (get_identifier ("expected_throw"),
   10220       426146 :                    NULL, DECL_ATTRIBUTES (decl));
   10221              : 
   10222     33402917 :   if (flags & ECF_CB_1_2)
   10223              :     {
   10224       392076 :       tree attr = callback_build_attr (1, 1, 2);
   10225       392076 :       TREE_CHAIN (attr) = DECL_ATTRIBUTES (decl);
   10226       392076 :       DECL_ATTRIBUTES (decl) = attr;
   10227              :     }
   10228              : 
   10229              :     /* Looping const or pure is implied by noreturn.
   10230              :      There is currently no way to declare looping const or looping pure alone.  */
   10231     33402917 :   gcc_assert (!(flags & ECF_LOOPING_CONST_OR_PURE)
   10232              :               || (flags & (ECF_CONST | ECF_PURE)));
   10233     33402917 : }
   10234              : 
   10235              : 
   10236              : /* A subroutine of build_common_builtin_nodes.  Define a builtin function.  */
   10237              : 
   10238              : static void
   10239      9814602 : local_define_builtin (const char *name, tree type, enum built_in_function code,
   10240              :                       const char *library_name, int ecf_flags)
   10241              : {
   10242      9814602 :   tree decl;
   10243              : 
   10244      9814602 :   decl = add_builtin_function (name, type, code, BUILT_IN_NORMAL,
   10245              :                                library_name, NULL_TREE);
   10246      9814602 :   set_call_expr_flags (decl, ecf_flags);
   10247              : 
   10248      9814602 :   set_builtin_decl (code, decl, true);
   10249      9814602 : }
   10250              : 
   10251              : /* Call this function after instantiating all builtins that the language
   10252              :    front end cares about.  This will build the rest of the builtins
   10253              :    and internal functions that are relied upon by the tree optimizers and
   10254              :    the middle-end.  */
   10255              : 
   10256              : void
   10257       296862 : build_common_builtin_nodes (void)
   10258              : {
   10259       296862 :   tree tmp, ftype;
   10260       296862 :   int ecf_flags;
   10261              : 
   10262       296862 :   if (!builtin_decl_explicit_p (BUILT_IN_CLEAR_PADDING))
   10263              :     {
   10264        60141 :       ftype = build_function_type_list (void_type_node,
   10265              :                                         ptr_type_node,
   10266              :                                         ptr_type_node,
   10267              :                                         NULL_TREE);
   10268        60141 :       local_define_builtin ("__builtin_clear_padding", ftype,
   10269              :                             BUILT_IN_CLEAR_PADDING,
   10270              :                             "__builtin_clear_padding",
   10271              :                             ECF_LEAF | ECF_NOTHROW);
   10272              :     }
   10273              : 
   10274       296862 :   if (!builtin_decl_explicit_p (BUILT_IN_UNREACHABLE)
   10275       246777 :       || !builtin_decl_explicit_p (BUILT_IN_TRAP)
   10276       246777 :       || !builtin_decl_explicit_p (BUILT_IN_UNREACHABLE_TRAP)
   10277       242131 :       || !builtin_decl_explicit_p (BUILT_IN_OBSERVABLE_CHKPT)
   10278       538993 :       || !builtin_decl_explicit_p (BUILT_IN_ABORT))
   10279              :     {
   10280        54731 :       ftype = build_function_type (void_type_node, void_list_node);
   10281        54731 :       if (!builtin_decl_explicit_p (BUILT_IN_UNREACHABLE))
   10282        50085 :         local_define_builtin ("__builtin_unreachable", ftype,
   10283              :                               BUILT_IN_UNREACHABLE,
   10284              :                               "__builtin_unreachable",
   10285              :                               ECF_NOTHROW | ECF_LEAF | ECF_NORETURN
   10286              :                               | ECF_CONST | ECF_COLD);
   10287        54731 :       if (!builtin_decl_explicit_p (BUILT_IN_UNREACHABLE_TRAP))
   10288        54731 :         local_define_builtin ("__builtin_unreachable trap", ftype,
   10289              :                               BUILT_IN_UNREACHABLE_TRAP,
   10290              :                               "__builtin_unreachable trap",
   10291              :                               ECF_NOTHROW | ECF_LEAF | ECF_NORETURN
   10292              :                               | ECF_CONST | ECF_COLD);
   10293        54731 :       if (!builtin_decl_explicit_p (BUILT_IN_ABORT))
   10294        54731 :         local_define_builtin ("__builtin_abort", ftype, BUILT_IN_ABORT,
   10295              :                               "abort",
   10296              :                               ECF_LEAF | ECF_NORETURN | ECF_CONST | ECF_COLD);
   10297        54731 :       if (!builtin_decl_explicit_p (BUILT_IN_TRAP))
   10298        17412 :         local_define_builtin ("__builtin_trap", ftype, BUILT_IN_TRAP,
   10299              :                               "__builtin_trap",
   10300              :                               ECF_NORETURN | ECF_NOTHROW | ECF_LEAF | ECF_COLD);
   10301        54731 :       if (!builtin_decl_explicit_p (BUILT_IN_OBSERVABLE_CHKPT))
   10302        54731 :         local_define_builtin ("__builtin_observable_checkpoint", ftype,
   10303              :                               BUILT_IN_OBSERVABLE_CHKPT,
   10304              :                               "__builtin_observable_checkpoint",
   10305              :                               ECF_NOTHROW | ECF_LEAF | ECF_CONST
   10306              :                               | ECF_LOOPING_CONST_OR_PURE);
   10307              :     }
   10308              : 
   10309       296862 :   if (!builtin_decl_explicit_p (BUILT_IN_MEMCPY)
   10310       296862 :       || !builtin_decl_explicit_p (BUILT_IN_MEMMOVE))
   10311              :     {
   10312        54731 :       ftype = build_function_type_list (ptr_type_node,
   10313              :                                         ptr_type_node, const_ptr_type_node,
   10314              :                                         size_type_node, NULL_TREE);
   10315              : 
   10316        54731 :       if (!builtin_decl_explicit_p (BUILT_IN_MEMCPY))
   10317        54731 :         local_define_builtin ("__builtin_memcpy", ftype, BUILT_IN_MEMCPY,
   10318              :                               "memcpy", ECF_NOTHROW | ECF_LEAF);
   10319        54731 :       if (!builtin_decl_explicit_p (BUILT_IN_MEMMOVE))
   10320        50085 :         local_define_builtin ("__builtin_memmove", ftype, BUILT_IN_MEMMOVE,
   10321              :                               "memmove", ECF_NOTHROW | ECF_LEAF);
   10322              :     }
   10323              : 
   10324       296862 :   if (!builtin_decl_explicit_p (BUILT_IN_MEMCMP))
   10325              :     {
   10326        50085 :       ftype = build_function_type_list (integer_type_node, const_ptr_type_node,
   10327              :                                         const_ptr_type_node, size_type_node,
   10328              :                                         NULL_TREE);
   10329        50085 :       local_define_builtin ("__builtin_memcmp", ftype, BUILT_IN_MEMCMP,
   10330              :                             "memcmp", ECF_PURE | ECF_NOTHROW | ECF_LEAF);
   10331              :     }
   10332              : 
   10333       296862 :   if (!builtin_decl_explicit_p (BUILT_IN_MEMSET))
   10334              :     {
   10335        50085 :       ftype = build_function_type_list (ptr_type_node,
   10336              :                                         ptr_type_node, integer_type_node,
   10337              :                                         size_type_node, NULL_TREE);
   10338        50085 :       local_define_builtin ("__builtin_memset", ftype, BUILT_IN_MEMSET,
   10339              :                             "memset", ECF_NOTHROW | ECF_LEAF);
   10340              :     }
   10341              : 
   10342              :   /* If we're checking the stack, `alloca' can throw.  */
   10343       296793 :   const int alloca_flags
   10344       296862 :     = ECF_MALLOC | ECF_LEAF | (flag_stack_check ? 0 : ECF_NOTHROW);
   10345              : 
   10346       296862 :   if (!builtin_decl_explicit_p (BUILT_IN_ALLOCA))
   10347              :     {
   10348        54731 :       ftype = build_function_type_list (ptr_type_node,
   10349              :                                         size_type_node, NULL_TREE);
   10350        54731 :       local_define_builtin ("__builtin_alloca", ftype, BUILT_IN_ALLOCA,
   10351              :                             "alloca", alloca_flags);
   10352              :     }
   10353              : 
   10354       296862 :   ftype = build_function_type_list (ptr_type_node, size_type_node,
   10355              :                                     size_type_node, NULL_TREE);
   10356       296862 :   local_define_builtin ("__builtin_alloca_with_align", ftype,
   10357              :                         BUILT_IN_ALLOCA_WITH_ALIGN,
   10358              :                         "__builtin_alloca_with_align",
   10359              :                         alloca_flags);
   10360              : 
   10361       296862 :   ftype = build_function_type_list (ptr_type_node, size_type_node,
   10362              :                                     size_type_node, size_type_node, NULL_TREE);
   10363       296862 :   local_define_builtin ("__builtin_alloca_with_align_and_max", ftype,
   10364              :                         BUILT_IN_ALLOCA_WITH_ALIGN_AND_MAX,
   10365              :                         "__builtin_alloca_with_align_and_max",
   10366              :                         alloca_flags);
   10367              : 
   10368       296862 :   ftype = build_function_type_list (void_type_node,
   10369              :                                     ptr_type_node, ptr_type_node,
   10370              :                                     ptr_type_node, NULL_TREE);
   10371       296862 :   local_define_builtin ("__builtin_init_trampoline", ftype,
   10372              :                         BUILT_IN_INIT_TRAMPOLINE,
   10373              :                         "__builtin_init_trampoline", ECF_NOTHROW | ECF_LEAF);
   10374       296862 :   local_define_builtin ("__builtin_init_heap_trampoline", ftype,
   10375              :                         BUILT_IN_INIT_HEAP_TRAMPOLINE,
   10376              :                         "__builtin_init_heap_trampoline",
   10377              :                         ECF_NOTHROW | ECF_LEAF);
   10378       296862 :   local_define_builtin ("__builtin_init_descriptor", ftype,
   10379              :                         BUILT_IN_INIT_DESCRIPTOR,
   10380              :                         "__builtin_init_descriptor", ECF_NOTHROW | ECF_LEAF);
   10381              : 
   10382       296862 :   ftype = build_function_type_list (ptr_type_node, ptr_type_node, NULL_TREE);
   10383       296862 :   local_define_builtin ("__builtin_adjust_trampoline", ftype,
   10384              :                         BUILT_IN_ADJUST_TRAMPOLINE,
   10385              :                         "__builtin_adjust_trampoline",
   10386              :                         ECF_CONST | ECF_NOTHROW);
   10387       296862 :   local_define_builtin ("__builtin_adjust_descriptor", ftype,
   10388              :                         BUILT_IN_ADJUST_DESCRIPTOR,
   10389              :                         "__builtin_adjust_descriptor",
   10390              :                         ECF_CONST | ECF_NOTHROW);
   10391              : 
   10392       296862 :   ftype = build_function_type_list (void_type_node,
   10393              :                                     ptr_type_node, ptr_type_node, NULL_TREE);
   10394       296862 :   if (!builtin_decl_explicit_p (BUILT_IN_CLEAR_CACHE))
   10395        54731 :     local_define_builtin ("__builtin___clear_cache", ftype,
   10396              :                           BUILT_IN_CLEAR_CACHE,
   10397              :                           "__clear_cache",
   10398              :                           ECF_NOTHROW);
   10399              : 
   10400       296862 :   local_define_builtin ("__builtin_nonlocal_goto", ftype,
   10401              :                         BUILT_IN_NONLOCAL_GOTO,
   10402              :                         "__builtin_nonlocal_goto",
   10403              :                         ECF_NORETURN | ECF_NOTHROW);
   10404              : 
   10405       296862 :   tree ptr_ptr_type_node = build_pointer_type (ptr_type_node);
   10406              : 
   10407       296862 :   if (!builtin_decl_explicit_p (BUILT_IN_GCC_NESTED_PTR_CREATED))
   10408              :     {
   10409        54731 :       ftype = build_function_type_list (void_type_node,
   10410              :                                         ptr_type_node, // void *chain
   10411              :                                         ptr_type_node, // void *func
   10412              :                                         ptr_ptr_type_node, // void **dst
   10413              :                                         NULL_TREE);
   10414        54731 :       local_define_builtin ("__builtin___gcc_nested_func_ptr_created", ftype,
   10415              :                             BUILT_IN_GCC_NESTED_PTR_CREATED,
   10416              :                             "__gcc_nested_func_ptr_created", ECF_NOTHROW);
   10417              :     }
   10418              : 
   10419       296862 :   if (!builtin_decl_explicit_p (BUILT_IN_GCC_NESTED_PTR_DELETED))
   10420              :     {
   10421        54731 :       ftype = build_function_type_list (void_type_node, NULL_TREE);
   10422        54731 :       local_define_builtin ("__builtin___gcc_nested_func_ptr_deleted", ftype,
   10423              :                             BUILT_IN_GCC_NESTED_PTR_DELETED,
   10424              :                             "__gcc_nested_func_ptr_deleted", ECF_NOTHROW);
   10425              :     }
   10426              : 
   10427       296862 :   ftype = build_function_type_list (void_type_node,
   10428              :                                     ptr_type_node, ptr_type_node, NULL_TREE);
   10429       296862 :   local_define_builtin ("__builtin_setjmp_setup", ftype,
   10430              :                         BUILT_IN_SETJMP_SETUP,
   10431              :                         "__builtin_setjmp_setup", ECF_NOTHROW);
   10432              : 
   10433       296862 :   ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
   10434       296862 :   local_define_builtin ("__builtin_setjmp_receiver", ftype,
   10435              :                         BUILT_IN_SETJMP_RECEIVER,
   10436              :                         "__builtin_setjmp_receiver", ECF_NOTHROW | ECF_LEAF);
   10437              : 
   10438       296862 :   ftype = build_function_type_list (ptr_type_node, NULL_TREE);
   10439       296862 :   local_define_builtin ("__builtin_stack_save", ftype, BUILT_IN_STACK_SAVE,
   10440              :                         "__builtin_stack_save", ECF_NOTHROW | ECF_LEAF);
   10441              : 
   10442       296862 :   ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
   10443       296862 :   local_define_builtin ("__builtin_stack_restore", ftype,
   10444              :                         BUILT_IN_STACK_RESTORE,
   10445              :                         "__builtin_stack_restore", ECF_NOTHROW | ECF_LEAF);
   10446              : 
   10447       296862 :   ftype = build_function_type_list (integer_type_node, const_ptr_type_node,
   10448              :                                     const_ptr_type_node, size_type_node,
   10449              :                                     NULL_TREE);
   10450       296862 :   local_define_builtin ("__builtin_memcmp_eq", ftype, BUILT_IN_MEMCMP_EQ,
   10451              :                         "__builtin_memcmp_eq",
   10452              :                         ECF_PURE | ECF_NOTHROW | ECF_LEAF);
   10453              : 
   10454       296862 :   local_define_builtin ("__builtin_strncmp_eq", ftype, BUILT_IN_STRNCMP_EQ,
   10455              :                         "__builtin_strncmp_eq",
   10456              :                         ECF_PURE | ECF_NOTHROW | ECF_LEAF);
   10457              : 
   10458       296862 :   local_define_builtin ("__builtin_strcmp_eq", ftype, BUILT_IN_STRCMP_EQ,
   10459              :                         "__builtin_strcmp_eq",
   10460              :                         ECF_PURE | ECF_NOTHROW | ECF_LEAF);
   10461              : 
   10462              :   /* If there's a possibility that we might use the ARM EABI, build the
   10463              :     alternate __cxa_end_cleanup node used to resume from C++.  */
   10464       296862 :   if (targetm.arm_eabi_unwinder)
   10465              :     {
   10466            0 :       ftype = build_function_type_list (void_type_node, NULL_TREE);
   10467            0 :       local_define_builtin ("__builtin_cxa_end_cleanup", ftype,
   10468              :                             BUILT_IN_CXA_END_CLEANUP,
   10469              :                             "__cxa_end_cleanup",
   10470              :                             ECF_NORETURN | ECF_XTHROW | ECF_LEAF);
   10471              :     }
   10472              : 
   10473       296862 :   ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
   10474       593724 :   local_define_builtin ("__builtin_unwind_resume", ftype,
   10475              :                         BUILT_IN_UNWIND_RESUME,
   10476       296862 :                         ((targetm_common.except_unwind_info (&global_options)
   10477              :                           == UI_SJLJ)
   10478              :                          ? "_Unwind_SjLj_Resume" : "_Unwind_Resume"),
   10479              :                         ECF_NORETURN | ECF_XTHROW);
   10480              : 
   10481       296862 :   if (builtin_decl_explicit (BUILT_IN_RETURN_ADDRESS) == NULL_TREE)
   10482              :     {
   10483        50085 :       ftype = build_function_type_list (ptr_type_node, integer_type_node,
   10484              :                                         NULL_TREE);
   10485        50085 :       local_define_builtin ("__builtin_return_address", ftype,
   10486              :                             BUILT_IN_RETURN_ADDRESS,
   10487              :                             "__builtin_return_address",
   10488              :                             ECF_NOTHROW);
   10489              :     }
   10490              : 
   10491       296862 :   if (!builtin_decl_explicit_p (BUILT_IN_PROFILE_FUNC_ENTER)
   10492       296862 :       || !builtin_decl_explicit_p (BUILT_IN_PROFILE_FUNC_EXIT))
   10493              :     {
   10494        54731 :       ftype = build_function_type_list (void_type_node, ptr_type_node,
   10495              :                                         ptr_type_node, NULL_TREE);
   10496        54731 :       if (!builtin_decl_explicit_p (BUILT_IN_PROFILE_FUNC_ENTER))
   10497        54731 :         local_define_builtin ("__cyg_profile_func_enter", ftype,
   10498              :                               BUILT_IN_PROFILE_FUNC_ENTER,
   10499              :                               "__cyg_profile_func_enter", 0);
   10500        54731 :       if (!builtin_decl_explicit_p (BUILT_IN_PROFILE_FUNC_EXIT))
   10501        54731 :         local_define_builtin ("__cyg_profile_func_exit", ftype,
   10502              :                               BUILT_IN_PROFILE_FUNC_EXIT,
   10503              :                               "__cyg_profile_func_exit", 0);
   10504              :     }
   10505              : 
   10506              :   /* The exception object and filter values from the runtime.  The argument
   10507              :      must be zero before exception lowering, i.e. from the front end.  After
   10508              :      exception lowering, it will be the region number for the exception
   10509              :      landing pad.  These functions are PURE instead of CONST to prevent
   10510              :      them from being hoisted past the exception edge that will initialize
   10511              :      its value in the landing pad.  */
   10512       296862 :   ftype = build_function_type_list (ptr_type_node,
   10513              :                                     integer_type_node, NULL_TREE);
   10514       296862 :   ecf_flags = ECF_PURE | ECF_NOTHROW | ECF_LEAF;
   10515              :   /* Only use TM_PURE if we have TM language support.  */
   10516       296862 :   if (builtin_decl_explicit_p (BUILT_IN_TM_LOAD_1))
   10517          473 :     ecf_flags |= ECF_TM_PURE;
   10518       296862 :   local_define_builtin ("__builtin_eh_pointer", ftype, BUILT_IN_EH_POINTER,
   10519              :                         "__builtin_eh_pointer", ecf_flags);
   10520              : 
   10521       296862 :   tmp = lang_hooks.types.type_for_mode (targetm.eh_return_filter_mode (), 0);
   10522       296862 :   ftype = build_function_type_list (tmp, integer_type_node, NULL_TREE);
   10523       296862 :   local_define_builtin ("__builtin_eh_filter", ftype, BUILT_IN_EH_FILTER,
   10524              :                         "__builtin_eh_filter", ECF_PURE | ECF_NOTHROW | ECF_LEAF);
   10525              : 
   10526       296862 :   ftype = build_function_type_list (void_type_node,
   10527              :                                     integer_type_node, integer_type_node,
   10528              :                                     NULL_TREE);
   10529       296862 :   local_define_builtin ("__builtin_eh_copy_values", ftype,
   10530              :                         BUILT_IN_EH_COPY_VALUES,
   10531              :                         "__builtin_eh_copy_values", ECF_NOTHROW);
   10532              : 
   10533              :   /* Complex multiplication and division.  These are handled as builtins
   10534              :      rather than optabs because emit_library_call_value doesn't support
   10535              :      complex.  Further, we can do slightly better with folding these
   10536              :      beasties if the real and complex parts of the arguments are separate.  */
   10537       296862 :   {
   10538       296862 :     int mode;
   10539              : 
   10540      2374896 :     for (mode = MIN_MODE_COMPLEX_FLOAT; mode <= MAX_MODE_COMPLEX_FLOAT; ++mode)
   10541              :       {
   10542      1781172 :         char mode_name_buf[4], *q;
   10543      1781172 :         const char *p;
   10544      1781172 :         enum built_in_function mcode, dcode;
   10545      1781172 :         tree type, inner_type;
   10546      1781172 :         const char *prefix = "__";
   10547              : 
   10548      1781172 :         if (targetm.libfunc_gnu_prefix)
   10549            0 :           prefix = "__gnu_";
   10550              : 
   10551      1781172 :         type = lang_hooks.types.type_for_mode ((machine_mode) mode, 0);
   10552      1781172 :         if (type == NULL)
   10553       131704 :           continue;
   10554      1649468 :         inner_type = TREE_TYPE (type);
   10555              : 
   10556      1649468 :         ftype = build_function_type_list (type, inner_type, inner_type,
   10557              :                                           inner_type, inner_type, NULL_TREE);
   10558              : 
   10559      1649468 :         mcode = ((enum built_in_function)
   10560      1649468 :                  (BUILT_IN_COMPLEX_MUL_MIN + mode - MIN_MODE_COMPLEX_FLOAT));
   10561      1649468 :         dcode = ((enum built_in_function)
   10562      1649468 :                  (BUILT_IN_COMPLEX_DIV_MIN + mode - MIN_MODE_COMPLEX_FLOAT));
   10563              : 
   10564      4948404 :         for (p = GET_MODE_NAME (mode), q = mode_name_buf; *p; p++, q++)
   10565      3298936 :           *q = TOLOWER (*p);
   10566      1649468 :         *q = '\0';
   10567              : 
   10568              :         /* For -ftrapping-math these should throw from a former
   10569              :            -fnon-call-exception stmt.  */
   10570      1649468 :         built_in_names[mcode] = concat (prefix, "mul", mode_name_buf, "3",
   10571              :                                         NULL);
   10572      1649468 :         local_define_builtin (built_in_names[mcode], ftype, mcode,
   10573              :                               built_in_names[mcode],
   10574              :                               ECF_CONST | ECF_LEAF);
   10575              : 
   10576      1649468 :         built_in_names[dcode] = concat (prefix, "div", mode_name_buf, "3",
   10577              :                                         NULL);
   10578      1649468 :         local_define_builtin (built_in_names[dcode], ftype, dcode,
   10579              :                               built_in_names[dcode],
   10580              :                               ECF_CONST | ECF_LEAF);
   10581              :       }
   10582              :   }
   10583              : 
   10584       296862 :   init_internal_fns ();
   10585       296862 : }
   10586              : 
   10587              : /* HACK.  GROSS.  This is absolutely disgusting.  I wish there was a
   10588              :    better way.
   10589              : 
   10590              :    If we requested a pointer to a vector, build up the pointers that
   10591              :    we stripped off while looking for the inner type.  Similarly for
   10592              :    return values from functions.
   10593              : 
   10594              :    The argument TYPE is the top of the chain, and BOTTOM is the
   10595              :    new type which we will point to.  */
   10596              : 
   10597              : tree
   10598            0 : reconstruct_complex_type (tree type, tree bottom)
   10599              : {
   10600            0 :   tree inner, outer;
   10601              : 
   10602            0 :   if (TREE_CODE (type) == POINTER_TYPE)
   10603              :     {
   10604            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10605            0 :       outer = build_pointer_type_for_mode (inner, TYPE_MODE (type),
   10606            0 :                                            TYPE_REF_CAN_ALIAS_ALL (type));
   10607              :     }
   10608              :   else if (TREE_CODE (type) == REFERENCE_TYPE)
   10609              :     {
   10610            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10611            0 :       outer = build_reference_type_for_mode (inner, TYPE_MODE (type),
   10612            0 :                                              TYPE_REF_CAN_ALIAS_ALL (type));
   10613              :     }
   10614              :   else if (TREE_CODE (type) == ARRAY_TYPE)
   10615              :     {
   10616            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10617            0 :       outer = build_array_type (inner, TYPE_DOMAIN (type));
   10618              :     }
   10619              :   else if (TREE_CODE (type) == FUNCTION_TYPE)
   10620              :     {
   10621            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10622            0 :       outer = build_function_type (inner, TYPE_ARG_TYPES (type),
   10623            0 :                                    TYPE_NO_NAMED_ARGS_STDARG_P (type));
   10624              :     }
   10625              :   else if (TREE_CODE (type) == METHOD_TYPE)
   10626              :     {
   10627            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10628              :       /* The build_method_type_directly() routine prepends 'this' to argument list,
   10629              :          so we must compensate by getting rid of it.  */
   10630            0 :       outer
   10631              :         = build_method_type_directly
   10632            0 :             (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (type))),
   10633              :              inner,
   10634            0 :              TREE_CHAIN (TYPE_ARG_TYPES (type)));
   10635              :     }
   10636              :   else if (TREE_CODE (type) == OFFSET_TYPE)
   10637              :     {
   10638            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10639            0 :       outer = build_offset_type (TYPE_OFFSET_BASETYPE (type), inner);
   10640              :     }
   10641              :   else
   10642              :     return bottom;
   10643              : 
   10644            0 :   return build_type_attribute_qual_variant (outer, TYPE_ATTRIBUTES (type),
   10645            0 :                                             TYPE_QUALS (type));
   10646              : }
   10647              : 
   10648              : /* Returns a vector tree node given a mode (integer, vector, or BLKmode) and
   10649              :    the inner type.  */
   10650              : tree
   10651     33574634 : build_vector_type_for_mode (tree innertype, machine_mode mode)
   10652              : {
   10653     33574634 :   poly_int64 nunits;
   10654     33574634 :   unsigned int bitsize;
   10655              : 
   10656     33574634 :   switch (GET_MODE_CLASS (mode))
   10657              :     {
   10658     33573236 :     case MODE_VECTOR_BOOL:
   10659     33573236 :     case MODE_VECTOR_INT:
   10660     33573236 :     case MODE_VECTOR_FLOAT:
   10661     33573236 :     case MODE_VECTOR_FRACT:
   10662     33573236 :     case MODE_VECTOR_UFRACT:
   10663     33573236 :     case MODE_VECTOR_ACCUM:
   10664     33573236 :     case MODE_VECTOR_UACCUM:
   10665     67146472 :       nunits = GET_MODE_NUNITS (mode);
   10666     33573236 :       break;
   10667              : 
   10668         1398 :     case MODE_INT:
   10669              :       /* Check that there are no leftover bits.  */
   10670         1398 :       bitsize = GET_MODE_BITSIZE (as_a <scalar_int_mode> (mode));
   10671         1398 :       gcc_assert (bitsize % TREE_INT_CST_LOW (TYPE_SIZE (innertype)) == 0);
   10672         1398 :       nunits = bitsize / TREE_INT_CST_LOW (TYPE_SIZE (innertype));
   10673         1398 :       break;
   10674              : 
   10675            0 :     default:
   10676            0 :       gcc_unreachable ();
   10677              :     }
   10678              : 
   10679     33574634 :   return make_vector_type (innertype, nunits, mode);
   10680              : }
   10681              : 
   10682              : /* Similarly, but takes the inner type and number of units, which must be
   10683              :    a power of two.  */
   10684              : 
   10685              : tree
   10686      2978064 : build_vector_type (tree innertype, poly_int64 nunits)
   10687              : {
   10688      2978064 :   return make_vector_type (innertype, nunits, VOIDmode);
   10689              : }
   10690              : 
   10691              : /* Build a truth vector with NUNITS units, giving it mode MASK_MODE.  */
   10692              : 
   10693              : tree
   10694      2658197 : build_truth_vector_type_for_mode (poly_uint64 nunits, machine_mode mask_mode)
   10695              : {
   10696      2658197 :   gcc_assert (mask_mode != BLKmode);
   10697              : 
   10698      2658197 :   unsigned HOST_WIDE_INT esize;
   10699      2658197 :   if (VECTOR_MODE_P (mask_mode))
   10700              :     {
   10701      2511720 :       poly_uint64 vsize = GET_MODE_PRECISION (mask_mode);
   10702      2511720 :       esize = vector_element_size (vsize, nunits);
   10703      2511720 :     }
   10704              :   else
   10705              :     esize = 1;
   10706              : 
   10707      2658197 :   tree bool_type = build_nonstandard_boolean_type (esize);
   10708              : 
   10709      2658197 :   return make_vector_type (bool_type, nunits, mask_mode);
   10710              : }
   10711              : 
   10712              : /* Build a vector type that holds one boolean result for each element of
   10713              :    vector type VECTYPE.  The public interface for this operation is
   10714              :    truth_type_for.  */
   10715              : 
   10716              : static tree
   10717      2647091 : build_truth_vector_type_for (tree vectype)
   10718              : {
   10719      2647091 :   machine_mode vector_mode = TYPE_MODE (vectype);
   10720      2647091 :   poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (vectype);
   10721              : 
   10722      2647091 :   machine_mode mask_mode;
   10723       109153 :   if (VECTOR_MODE_P (vector_mode)
   10724      2755623 :       && targetm.vectorize.get_mask_mode (vector_mode).exists (&mask_mode))
   10725      2646470 :     return build_truth_vector_type_for_mode (nunits, mask_mode);
   10726              : 
   10727          621 :   poly_uint64 vsize = tree_to_poly_uint64 (TYPE_SIZE (vectype));
   10728          621 :   unsigned HOST_WIDE_INT esize = vector_element_size (vsize, nunits);
   10729          621 :   tree bool_type = build_nonstandard_boolean_type (esize);
   10730              : 
   10731          621 :   return make_vector_type (bool_type, nunits, VOIDmode);
   10732              : }
   10733              : 
   10734              : /* Like build_vector_type, but builds a variant type with TYPE_VECTOR_OPAQUE
   10735              :    set.  */
   10736              : 
   10737              : tree
   10738       110771 : build_opaque_vector_type (tree innertype, poly_int64 nunits)
   10739              : {
   10740       110771 :   tree t = make_vector_type (innertype, nunits, VOIDmode);
   10741       110771 :   tree cand;
   10742              :   /* We always build the non-opaque variant before the opaque one,
   10743              :      so if it already exists, it is TYPE_NEXT_VARIANT of this one.  */
   10744       110771 :   cand = TYPE_NEXT_VARIANT (t);
   10745       110771 :   if (cand
   10746        98995 :       && TYPE_VECTOR_OPAQUE (cand)
   10747       174824 :       && check_qualified_type (cand, t, TYPE_QUALS (t)))
   10748        64052 :     return cand;
   10749              :   /* Otherwise build a variant type and make sure to queue it after
   10750              :      the non-opaque type.  */
   10751        46719 :   cand = build_distinct_type_copy (t);
   10752        46719 :   TYPE_VECTOR_OPAQUE (cand) = true;
   10753        46719 :   TYPE_CANONICAL (cand) = TYPE_CANONICAL (t);
   10754        46719 :   TYPE_NEXT_VARIANT (cand) = TYPE_NEXT_VARIANT (t);
   10755        46719 :   TYPE_NEXT_VARIANT (t) = cand;
   10756        46719 :   TYPE_MAIN_VARIANT (cand) = TYPE_MAIN_VARIANT (t);
   10757              :   /* Type variants have no alias set defined.  */
   10758        46719 :   TYPE_ALIAS_SET (cand) = -1;
   10759        46719 :   return cand;
   10760              : }
   10761              : 
   10762              : /* Return the value of element I of VECTOR_CST T as a wide_int.  */
   10763              : 
   10764              : static poly_wide_int
   10765       549443 : vector_cst_int_elt (const_tree t, unsigned int i)
   10766              : {
   10767              :   /* First handle elements that are directly encoded.  */
   10768       549443 :   unsigned int encoded_nelts = vector_cst_encoded_nelts (t);
   10769       549443 :   if (i < encoded_nelts)
   10770            0 :     return wi::to_poly_wide (VECTOR_CST_ENCODED_ELT (t, i));
   10771              : 
   10772              :   /* Identify the pattern that contains element I and work out the index of
   10773              :      the last encoded element for that pattern.  */
   10774       549443 :   unsigned int npatterns = VECTOR_CST_NPATTERNS (t);
   10775       549443 :   unsigned int pattern = i % npatterns;
   10776       549443 :   unsigned int count = i / npatterns;
   10777       549443 :   unsigned int final_i = encoded_nelts - npatterns + pattern;
   10778              : 
   10779              :   /* If there are no steps, the final encoded value is the right one.  */
   10780       549443 :   if (!VECTOR_CST_STEPPED_P (t))
   10781            0 :     return wi::to_poly_wide (VECTOR_CST_ENCODED_ELT (t, final_i));
   10782              : 
   10783              :   /* Otherwise work out the value from the last two encoded elements.  */
   10784       549443 :   tree v1 = VECTOR_CST_ENCODED_ELT (t, final_i - npatterns);
   10785       549443 :   tree v2 = VECTOR_CST_ENCODED_ELT (t, final_i);
   10786       549443 :   poly_wide_int diff = wi::to_poly_wide (v2) - wi::to_poly_wide (v1);
   10787       549443 :   return wi::to_poly_wide (v2) + (count - 2) * diff;
   10788       549443 : }
   10789              : 
   10790              : /* Return the value of element I of VECTOR_CST T.  */
   10791              : 
   10792              : tree
   10793      8323303 : vector_cst_elt (const_tree t, unsigned int i)
   10794              : {
   10795              :   /* First handle elements that are directly encoded.  */
   10796      8323303 :   unsigned int encoded_nelts = vector_cst_encoded_nelts (t);
   10797      8323303 :   if (i < encoded_nelts)
   10798      5354323 :     return VECTOR_CST_ENCODED_ELT (t, i);
   10799              : 
   10800              :   /* If there are no steps, the final encoded value is the right one.  */
   10801      2968980 :   if (!VECTOR_CST_STEPPED_P (t))
   10802              :     {
   10803              :       /* Identify the pattern that contains element I and work out the index of
   10804              :          the last encoded element for that pattern.  */
   10805      2419537 :       unsigned int npatterns = VECTOR_CST_NPATTERNS (t);
   10806      2419537 :       unsigned int pattern = i % npatterns;
   10807      2419537 :       unsigned int final_i = encoded_nelts - npatterns + pattern;
   10808      2419537 :       return VECTOR_CST_ENCODED_ELT (t, final_i);
   10809              :     }
   10810              : 
   10811              :   /* Otherwise work out the value from the last two encoded elements.  */
   10812       549443 :   return wide_int_to_tree (TREE_TYPE (TREE_TYPE (t)),
   10813      1098886 :                            vector_cst_int_elt (t, i));
   10814              : }
   10815              : 
   10816              : /* Given an initializer INIT, return TRUE if INIT is zero or some
   10817              :    aggregate of zeros.  Otherwise return FALSE.  If NONZERO is not
   10818              :    null, set *NONZERO if and only if INIT is known not to be all
   10819              :    zeros.  The combination of return value of false and *NONZERO
   10820              :    false implies that INIT may but need not be all zeros.  Other
   10821              :    combinations indicate definitive answers.  */
   10822              : 
   10823              : bool
   10824     44958178 : initializer_zerop (const_tree init, bool *nonzero /* = NULL */)
   10825              : {
   10826     44958178 :   bool dummy;
   10827     44958178 :   if (!nonzero)
   10828     42168434 :     nonzero = &dummy;
   10829              : 
   10830              :   /* Conservatively clear NONZERO and set it only if INIT is definitely
   10831              :      not all zero.  */
   10832     44958178 :   *nonzero = false;
   10833              : 
   10834     44958178 :   STRIP_NOPS (init);
   10835              : 
   10836     44958178 :   unsigned HOST_WIDE_INT off = 0;
   10837              : 
   10838     44958178 :   switch (TREE_CODE (init))
   10839              :     {
   10840     17374128 :     case INTEGER_CST:
   10841     17374128 :       if (integer_zerop (init))
   10842              :         return true;
   10843              : 
   10844     11075061 :       *nonzero = true;
   10845     11075061 :       return false;
   10846              : 
   10847       586707 :     case REAL_CST:
   10848              :       /* ??? Note that this is not correct for C4X float formats.  There,
   10849              :          a bit pattern of all zeros is 1.0; 0.0 is encoded with the most
   10850              :          negative exponent.  */
   10851       586707 :       if (real_zerop (init)
   10852       686801 :           && !REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (init)))
   10853              :         return true;
   10854              : 
   10855       489851 :       *nonzero = true;
   10856       489851 :       return false;
   10857              : 
   10858            0 :     case FIXED_CST:
   10859            0 :       if (fixed_zerop (init))
   10860              :         return true;
   10861              : 
   10862            0 :       *nonzero = true;
   10863            0 :       return false;
   10864              : 
   10865        18430 :     case COMPLEX_CST:
   10866        18430 :       if (integer_zerop (init)
   10867        18430 :           || (real_zerop (init)
   10868         3250 :               && !REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (TREE_REALPART (init)))
   10869         3170 :               && !REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (TREE_IMAGPART (init)))))
   10870              :         return true;
   10871              : 
   10872        15078 :       *nonzero = true;
   10873        15078 :       return false;
   10874              : 
   10875      1190196 :     case VECTOR_CST:
   10876      1190196 :       if (VECTOR_CST_NPATTERNS (init) == 1
   10877      1094441 :           && VECTOR_CST_DUPLICATE_P (init)
   10878      1870814 :           && initializer_zerop (VECTOR_CST_ENCODED_ELT (init, 0)))
   10879              :         return true;
   10880              : 
   10881       836623 :       *nonzero = true;
   10882       836623 :       return false;
   10883              : 
   10884              :     case RAW_DATA_CST:
   10885         1965 :       for (unsigned int i = 0; i < (unsigned int) RAW_DATA_LENGTH (init); ++i)
   10886         1965 :         if (RAW_DATA_POINTER (init)[i])
   10887              :           {
   10888         1918 :             *nonzero = true;
   10889         1918 :             return false;
   10890              :           }
   10891              :       return true;
   10892              : 
   10893      4220146 :     case CONSTRUCTOR:
   10894      4220146 :       {
   10895      4220146 :         if (TREE_CLOBBER_P (init))
   10896              :           return false;
   10897              : 
   10898              :         unsigned HOST_WIDE_INT idx;
   10899              :         tree elt;
   10900              : 
   10901      3689714 :         FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (init), idx, elt)
   10902      2789744 :           if (!initializer_zerop (elt, nonzero))
   10903              :             return false;
   10904              : 
   10905              :         return true;
   10906              :       }
   10907              : 
   10908       377781 :     case MEM_REF:
   10909       377781 :       {
   10910       377781 :         tree arg = TREE_OPERAND (init, 0);
   10911       377781 :         if (TREE_CODE (arg) != ADDR_EXPR)
   10912              :           return false;
   10913        96485 :         tree offset = TREE_OPERAND (init, 1);
   10914        96485 :         if (TREE_CODE (offset) != INTEGER_CST
   10915        96485 :             || !tree_fits_uhwi_p (offset))
   10916              :           return false;
   10917        96485 :         off = tree_to_uhwi (offset);
   10918        96485 :         if (INT_MAX < off)
   10919              :           return false;
   10920        96481 :         arg = TREE_OPERAND (arg, 0);
   10921        96481 :         if (TREE_CODE (arg) != STRING_CST)
   10922              :           return false;
   10923              :         init = arg;
   10924              :       }
   10925              :       /* Fall through.  */
   10926              : 
   10927              :     case STRING_CST:
   10928              :       {
   10929              :         gcc_assert (off <= INT_MAX);
   10930              : 
   10931       165102 :         int i = off;
   10932       165102 :         int n = TREE_STRING_LENGTH (init);
   10933       165102 :         if (n <= i)
   10934              :           return false;
   10935              : 
   10936              :         /* We need to loop through all elements to handle cases like
   10937              :            "\0" and "\0foobar".  */
   10938       177019 :         for (i = 0; i < n; ++i)
   10939       171673 :           if (TREE_STRING_POINTER (init)[i] != '\0')
   10940              :             {
   10941       159723 :               *nonzero = true;
   10942       159723 :               return false;
   10943              :             }
   10944              : 
   10945              :         return true;
   10946              :       }
   10947              : 
   10948              :     default:
   10949              :       return false;
   10950              :     }
   10951              : }
   10952              : 
   10953              : /* Return true if EXPR is an initializer expression in which every element
   10954              :    is a constant that is numerically equal to 0 or 1.  The elements do not
   10955              :    need to be equal to each other.  */
   10956              : 
   10957              : bool
   10958       138402 : initializer_each_zero_or_onep (const_tree expr)
   10959              : {
   10960       138402 :   STRIP_ANY_LOCATION_WRAPPER (expr);
   10961              : 
   10962       138402 :   switch (TREE_CODE (expr))
   10963              :     {
   10964        50169 :     case INTEGER_CST:
   10965        50169 :       return integer_zerop (expr) || integer_onep (expr);
   10966              : 
   10967        24870 :     case REAL_CST:
   10968        24870 :       return real_zerop (expr) || real_onep (expr);
   10969              : 
   10970        63363 :     case VECTOR_CST:
   10971        63363 :       {
   10972        63363 :         unsigned HOST_WIDE_INT nelts = vector_cst_encoded_nelts (expr);
   10973        63363 :         if (VECTOR_CST_STEPPED_P (expr)
   10974        63363 :             && !TYPE_VECTOR_SUBPARTS (TREE_TYPE (expr)).is_constant (&nelts))
   10975              :           return false;
   10976              : 
   10977        77490 :         for (unsigned int i = 0; i < nelts; ++i)
   10978              :           {
   10979        75039 :             tree elt = vector_cst_elt (expr, i);
   10980        75039 :             if (!initializer_each_zero_or_onep (elt))
   10981              :               return false;
   10982              :           }
   10983              : 
   10984              :         return true;
   10985              :       }
   10986              : 
   10987              :     default:
   10988              :       return false;
   10989              :     }
   10990              : }
   10991              : 
   10992              : /* Check if vector VEC consists of all the equal elements and
   10993              :    that the number of elements corresponds to the type of VEC.
   10994              :    The function returns first element of the vector
   10995              :    or NULL_TREE if the vector is not uniform.  */
   10996              : tree
   10997      3349865 : uniform_vector_p (const_tree vec)
   10998              : {
   10999      3349865 :   tree first, t;
   11000      3349865 :   unsigned HOST_WIDE_INT i, nelts;
   11001              : 
   11002      3349865 :   if (vec == NULL_TREE)
   11003              :     return NULL_TREE;
   11004              : 
   11005      3349865 :   gcc_assert (VECTOR_TYPE_P (TREE_TYPE (vec)));
   11006              : 
   11007      3349865 :   if (TREE_CODE (vec) == VEC_DUPLICATE_EXPR)
   11008            0 :     return TREE_OPERAND (vec, 0);
   11009              : 
   11010      3349865 :   else if (TREE_CODE (vec) == VECTOR_CST)
   11011              :     {
   11012       428048 :       if (VECTOR_CST_NPATTERNS (vec) == 1 && VECTOR_CST_DUPLICATE_P (vec))
   11013       360246 :         return VECTOR_CST_ENCODED_ELT (vec, 0);
   11014              :       return NULL_TREE;
   11015              :     }
   11016              : 
   11017      2921817 :   else if (TREE_CODE (vec) == CONSTRUCTOR
   11018      2921817 :            && TYPE_VECTOR_SUBPARTS (TREE_TYPE (vec)).is_constant (&nelts))
   11019              :     {
   11020       181071 :       first = error_mark_node;
   11021              : 
   11022       594339 :       FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (vec), i, t)
   11023              :         {
   11024       530511 :           if (i == 0)
   11025              :             {
   11026       181071 :               first = t;
   11027       181071 :               continue;
   11028              :             }
   11029       349440 :           if (!operand_equal_p (first, t, 0))
   11030              :             return NULL_TREE;
   11031              :         }
   11032        63828 :       if (i != nelts)
   11033              :         return NULL_TREE;
   11034              : 
   11035        63532 :       if (TREE_CODE (first) == CONSTRUCTOR || TREE_CODE (first) == VECTOR_CST)
   11036            0 :         return uniform_vector_p (first);
   11037              :       return first;
   11038              :     }
   11039              : 
   11040              :   return NULL_TREE;
   11041              : }
   11042              : 
   11043              : /* If OP is a uniform vector return the element it is a splat from.  */
   11044              : 
   11045              : tree
   11046       290983 : ssa_uniform_vector_p (tree op)
   11047              : {
   11048       290983 :   if (TREE_CODE (op) == VECTOR_CST
   11049              :       || TREE_CODE (op) == VEC_DUPLICATE_EXPR
   11050              :       || TREE_CODE (op) == CONSTRUCTOR)
   11051        12398 :     return uniform_vector_p (op);
   11052              :   if (TREE_CODE (op) == SSA_NAME)
   11053              :     {
   11054       278585 :       gimple *def_stmt = SSA_NAME_DEF_STMT (op);
   11055       278585 :       if (gimple_assign_single_p (def_stmt))
   11056       116365 :         return uniform_vector_p (gimple_assign_rhs1 (def_stmt));
   11057              :       /* A VEC_DUPLICATE_EXPR is a unary assignment, so it is not covered
   11058              :          by the gimple_assign_single_p case above.  */
   11059       162220 :       if (is_gimple_assign (def_stmt)
   11060       162220 :           && gimple_assign_rhs_code (def_stmt) == VEC_DUPLICATE_EXPR)
   11061            0 :         return gimple_assign_rhs1 (def_stmt);
   11062              :     }
   11063              :   return NULL_TREE;
   11064              : }
   11065              : 
   11066              : /* If the argument is INTEGER_CST, return it.  If the argument is vector
   11067              :    with all elements the same INTEGER_CST, return that INTEGER_CST.  Otherwise
   11068              :    return NULL_TREE.
   11069              :    Look through location wrappers. */
   11070              : 
   11071              : tree
   11072    885079028 : uniform_integer_cst_p (tree t)
   11073              : {
   11074    885079028 :   STRIP_ANY_LOCATION_WRAPPER (t);
   11075              : 
   11076    885079028 :   if (TREE_CODE (t) == INTEGER_CST)
   11077              :     return t;
   11078              : 
   11079    355977052 :   if (VECTOR_TYPE_P (TREE_TYPE (t)))
   11080              :     {
   11081      1421149 :       t = uniform_vector_p (t);
   11082      1421149 :       if (t && TREE_CODE (t) == INTEGER_CST)
   11083       301573 :         return t;
   11084              :     }
   11085              : 
   11086              :   return NULL_TREE;
   11087              : }
   11088              : 
   11089              : /* Return true if ELT1 and ELT2 are INTEGER_CSTs and if ELT1 - ELT2 is
   11090              :    consistent with the uniform difference recorded in DIFF.  */
   11091              : 
   11092              : static bool
   11093          307 : record_uniform_integer_difference (const_tree elt1, const_tree elt2,
   11094              :                                    widest_int *diff, bool *diff_p)
   11095              : {
   11096          307 :   STRIP_ANY_LOCATION_WRAPPER (elt1);
   11097          307 :   STRIP_ANY_LOCATION_WRAPPER (elt2);
   11098              : 
   11099          307 :   if (TREE_CODE (elt1) != INTEGER_CST
   11100          106 :       || TREE_CODE (elt2) != INTEGER_CST)
   11101              :     return false;
   11102              : 
   11103          106 :   widest_int elt_diff = wi::to_widest (elt1) - wi::to_widest (elt2);
   11104          106 :   if (!*diff_p)
   11105              :     {
   11106          106 :       *diff = elt_diff;
   11107          106 :       *diff_p = true;
   11108          106 :       return true;
   11109              :     }
   11110              : 
   11111            0 :   return *diff == elt_diff;
   11112          307 : }
   11113              : 
   11114              : /* Return the uniform difference between two INTEGER_CSTs or corresponding
   11115              :    elements of two VECTOR_CSTs or NULL_TREE if no such difference exists.  */
   11116              : 
   11117              : tree
   11118          307 : uniform_vector_difference_p (const_tree t1, const_tree t2)
   11119              : {
   11120          307 :   STRIP_ANY_LOCATION_WRAPPER (t1);
   11121          307 :   STRIP_ANY_LOCATION_WRAPPER (t2);
   11122              : 
   11123          307 :   if (TREE_CODE (t1) == INTEGER_CST
   11124            0 :       && TREE_CODE (t2) == INTEGER_CST)
   11125              :     {
   11126            0 :       widest_int diff = wi::to_widest (t1) - wi::to_widest (t2);
   11127            0 :       if (!wi::fits_shwi_p (diff))
   11128              :         return NULL_TREE;
   11129            0 :       return build_int_cst (long_long_integer_type_node, diff.to_shwi ());
   11130            0 :     }
   11131              : 
   11132          307 :   if (TREE_CODE (t1) != VECTOR_CST
   11133          307 :       || TREE_CODE (t2) != VECTOR_CST
   11134          614 :       || !known_eq (VECTOR_CST_NELTS (t1), VECTOR_CST_NELTS (t2)))
   11135              :     return NULL_TREE;
   11136              : 
   11137          307 :   widest_int diff;
   11138          307 :   bool diff_p = false;
   11139              : 
   11140          307 :   if (VECTOR_CST_LOG2_NPATTERNS (t1) == VECTOR_CST_LOG2_NPATTERNS (t2)
   11141          307 :       && (VECTOR_CST_NELTS_PER_PATTERN (t1)
   11142          307 :           == VECTOR_CST_NELTS_PER_PATTERN (t2)))
   11143              :     {
   11144          307 :       unsigned int encoded_nelts = vector_cst_encoded_nelts (t1);
   11145          307 :       gcc_assert (encoded_nelts == vector_cst_encoded_nelts (t2));
   11146              : 
   11147          413 :       for (unsigned int i = 0; i < encoded_nelts; ++i)
   11148          614 :         if (!record_uniform_integer_difference (VECTOR_CST_ENCODED_ELT (t1, i),
   11149          307 :                                                 VECTOR_CST_ENCODED_ELT (t2, i),
   11150              :                                                 &diff, &diff_p))
   11151              :           return NULL_TREE;
   11152              :     }
   11153              :   else
   11154              :     {
   11155            0 :       unsigned HOST_WIDE_INT nelts;
   11156            0 :       if (!VECTOR_CST_NELTS (t1).is_constant (&nelts))
   11157          307 :         return NULL_TREE;
   11158              : 
   11159            0 :       for (unsigned HOST_WIDE_INT i = 0; i < nelts; ++i)
   11160            0 :         if (!record_uniform_integer_difference (vector_cst_elt (t1, i),
   11161            0 :                                                 vector_cst_elt (t2, i),
   11162              :                                                 &diff, &diff_p))
   11163              :           return NULL_TREE;
   11164              :     }
   11165              : 
   11166          106 :   if (!diff_p || !wi::fits_shwi_p (diff))
   11167              :     return NULL_TREE;
   11168              : 
   11169          106 :   return build_int_cst (long_long_integer_type_node, diff.to_shwi ());
   11170          307 : }
   11171              : 
   11172              : /* Checks to see if T is a constant or a constant vector and if each element E
   11173              :    adheres to ~E + 1 == pow2 then return ~E otherwise NULL_TREE.  */
   11174              : 
   11175              : tree
   11176      3054362 : bitmask_inv_cst_vector_p (tree t)
   11177              : {
   11178              : 
   11179      3054362 :   tree_code code = TREE_CODE (t);
   11180      3054362 :   tree type = TREE_TYPE (t);
   11181              : 
   11182      3054362 :   if (!INTEGRAL_TYPE_P (type)
   11183      3054362 :       && !VECTOR_INTEGER_TYPE_P (type))
   11184              :     return NULL_TREE;
   11185              : 
   11186      3054334 :   unsigned HOST_WIDE_INT nelts = 1;
   11187      3054334 :   tree cst;
   11188      3054334 :   unsigned int idx = 0;
   11189      3054334 :   bool uniform = uniform_integer_cst_p (t);
   11190      3054334 :   tree newtype = unsigned_type_for (type);
   11191      3054334 :   tree_vector_builder builder;
   11192      3054334 :   if (code == INTEGER_CST)
   11193              :     cst = t;
   11194              :   else
   11195              :     {
   11196        18049 :       if (!VECTOR_CST_NELTS (t).is_constant (&nelts))
   11197              :         return NULL_TREE;
   11198              : 
   11199        18049 :       cst = vector_cst_elt (t, 0);
   11200        18049 :       builder.new_vector (newtype, nelts, 1);
   11201              :     }
   11202              : 
   11203      3054334 :   tree ty = unsigned_type_for (TREE_TYPE (cst));
   11204              : 
   11205      3054346 :   do
   11206              :     {
   11207      3054346 :       if (idx > 0)
   11208           12 :         cst = vector_cst_elt (t, idx);
   11209      3054346 :       wide_int icst = wi::to_wide (cst);
   11210      3054346 :       wide_int inv =  wi::bit_not (icst);
   11211      3054346 :       icst = wi::add (1, inv);
   11212      3054346 :       if (wi::popcount (icst) != 1)
   11213              :         return NULL_TREE;
   11214              : 
   11215        16028 :       tree newcst = wide_int_to_tree (ty, inv);
   11216              : 
   11217        16028 :       if (uniform)
   11218        16012 :         return build_uniform_cst (newtype, newcst);
   11219              : 
   11220           16 :       builder.quick_push (newcst);
   11221      3054346 :     }
   11222           16 :   while (++idx < nelts);
   11223              : 
   11224            4 :   return builder.build ();
   11225      3054334 : }
   11226              : 
   11227              : /* If VECTOR_CST T has a single nonzero element, return the index of that
   11228              :    element, otherwise return -1.  */
   11229              : 
   11230              : int
   11231          187 : single_nonzero_element (const_tree t)
   11232              : {
   11233          187 :   unsigned HOST_WIDE_INT nelts;
   11234          187 :   unsigned int repeat_nelts;
   11235          187 :   if (VECTOR_CST_NELTS (t).is_constant (&nelts))
   11236          187 :     repeat_nelts = nelts;
   11237              :   else if (VECTOR_CST_NELTS_PER_PATTERN (t) == 2)
   11238              :     {
   11239              :       nelts = vector_cst_encoded_nelts (t);
   11240              :       repeat_nelts = VECTOR_CST_NPATTERNS (t);
   11241              :     }
   11242              :   else
   11243              :     return -1;
   11244              : 
   11245          187 :   int res = -1;
   11246          581 :   for (unsigned int i = 0; i < nelts; ++i)
   11247              :     {
   11248          548 :       tree elt = vector_cst_elt (t, i);
   11249          548 :       if (!integer_zerop (elt) && !real_zerop (elt))
   11250              :         {
   11251          341 :           if (res >= 0 || i >= repeat_nelts)
   11252              :             return -1;
   11253          187 :           res = i;
   11254              :         }
   11255              :     }
   11256              :   return res;
   11257              : }
   11258              : 
   11259              : /* Build an empty statement at location LOC.  */
   11260              : 
   11261              : tree
   11262     16218104 : build_empty_stmt (location_t loc)
   11263              : {
   11264     16218104 :   tree t = build1 (NOP_EXPR, void_type_node, size_zero_node);
   11265     16218104 :   SET_EXPR_LOCATION (t, loc);
   11266     16218104 :   return t;
   11267              : }
   11268              : 
   11269              : 
   11270              : /* Build an OMP clause with code CODE.  LOC is the location of the
   11271              :    clause.  */
   11272              : 
   11273              : tree
   11274      1792306 : build_omp_clause (location_t loc, enum omp_clause_code code)
   11275              : {
   11276      1792306 :   tree t;
   11277      1792306 :   int size, length;
   11278              : 
   11279      1792306 :   length = omp_clause_num_ops[code];
   11280      1792306 :   size = (sizeof (struct tree_omp_clause) + (length - 1) * sizeof (tree));
   11281              : 
   11282      1792306 :   record_node_allocation_statistics (OMP_CLAUSE, size);
   11283              : 
   11284      1792306 :   t = (tree) ggc_internal_alloc (size);
   11285      1792306 :   memset (t, 0, size);
   11286      1792306 :   TREE_SET_CODE (t, OMP_CLAUSE);
   11287      1792306 :   OMP_CLAUSE_SET_CODE (t, code);
   11288      1792306 :   OMP_CLAUSE_LOCATION (t) = loc;
   11289              : 
   11290      1792306 :   return t;
   11291              : }
   11292              : 
   11293              : /* Build a tcc_vl_exp object with code CODE and room for LEN operands.  LEN
   11294              :    includes the implicit operand count in TREE_OPERAND 0, and so must be >= 1.
   11295              :    Except for the CODE and operand count field, other storage for the
   11296              :    object is initialized to zeros.  */
   11297              : 
   11298              : tree
   11299    546452141 : build_vl_exp (enum tree_code code, int len MEM_STAT_DECL)
   11300              : {
   11301    546452141 :   tree t;
   11302    546452141 :   int length = (len - 1) * sizeof (tree) + sizeof (struct tree_exp);
   11303              : 
   11304    546452141 :   gcc_assert (TREE_CODE_CLASS (code) == tcc_vl_exp);
   11305    546452141 :   gcc_assert (len >= 1);
   11306              : 
   11307    546452141 :   record_node_allocation_statistics (code, length);
   11308              : 
   11309    546452141 :   t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
   11310              : 
   11311    546452141 :   TREE_SET_CODE (t, code);
   11312              : 
   11313              :   /* Can't use TREE_OPERAND to store the length because if checking is
   11314              :      enabled, it will try to check the length before we store it.  :-P  */
   11315    546452141 :   t->exp.operands[0] = build_int_cst (sizetype, len);
   11316              : 
   11317    546452141 :   return t;
   11318              : }
   11319              : 
   11320              : /* Helper function for build_call_* functions; build a CALL_EXPR with
   11321              :    indicated RETURN_TYPE, FN, and NARGS, but do not initialize any of
   11322              :    the argument slots.  */
   11323              : 
   11324              : static tree
   11325    293920267 : build_call_1 (tree return_type, tree fn, int nargs)
   11326              : {
   11327    293920267 :   tree t;
   11328              : 
   11329    293920267 :   t = build_vl_exp (CALL_EXPR, nargs + 3);
   11330    293920267 :   TREE_TYPE (t) = return_type;
   11331    293920267 :   CALL_EXPR_FN (t) = fn;
   11332    293920267 :   CALL_EXPR_STATIC_CHAIN (t) = NULL;
   11333              : 
   11334    293920267 :   return t;
   11335              : }
   11336              : 
   11337              : /* Build a CALL_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE and
   11338              :    FN and a null static chain slot.  NARGS is the number of call arguments
   11339              :    which are specified as a va_list ARGS.  */
   11340              : 
   11341              : tree
   11342       136189 : build_call_valist (tree return_type, tree fn, int nargs, va_list args)
   11343              : {
   11344       136189 :   tree t;
   11345       136189 :   int i;
   11346              : 
   11347       136189 :   t = build_call_1 (return_type, fn, nargs);
   11348       552665 :   for (i = 0; i < nargs; i++)
   11349       280287 :     CALL_EXPR_ARG (t, i) = va_arg (args, tree);
   11350       136189 :   process_call_operands (t);
   11351       136189 :   return t;
   11352              : }
   11353              : 
   11354              : /* Build a CALL_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE and
   11355              :    FN and a null static chain slot.  ARGS specifies the call arguments.  */
   11356              : 
   11357              : tree
   11358          275 : build_call (tree return_type, tree fn, std::initializer_list<tree> args)
   11359              : {
   11360          275 :   tree t;
   11361          275 :   int i;
   11362          275 :   int nargs = args.size();
   11363              : 
   11364          275 :   t = build_call_1 (return_type, fn, nargs);
   11365         1051 :   for (i = 0; i < nargs; i++)
   11366          501 :     CALL_EXPR_ARG (t, i) = args.begin()[i];
   11367          275 :   process_call_operands (t);
   11368          275 :   return t;
   11369              : }
   11370              : 
   11371              : /* Build a CALL_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE and
   11372              :    FN and a null static chain slot.  NARGS is the number of call arguments
   11373              :    which are specified as a tree array ARGS.  */
   11374              : 
   11375              : tree
   11376    246280409 : build_call_array_loc (location_t loc, tree return_type, tree fn,
   11377              :                       int nargs, const tree *args)
   11378              : {
   11379    246280409 :   tree t;
   11380    246280409 :   int i;
   11381              : 
   11382    246280409 :   t = build_call_1 (return_type, fn, nargs);
   11383    824819264 :   for (i = 0; i < nargs; i++)
   11384    332258446 :     CALL_EXPR_ARG (t, i) = args[i];
   11385    246280409 :   process_call_operands (t);
   11386    246280409 :   SET_EXPR_LOCATION (t, loc);
   11387    246280409 :   return t;
   11388              : }
   11389              : 
   11390              : /* Like build_call_array, but takes a vec.  */
   11391              : 
   11392              : tree
   11393     46689642 : build_call_vec (tree return_type, tree fn, const vec<tree, va_gc> *args)
   11394              : {
   11395     46689642 :   tree ret, t;
   11396     46689642 :   unsigned int ix;
   11397              : 
   11398     46689642 :   ret = build_call_1 (return_type, fn, vec_safe_length (args));
   11399    128709342 :   FOR_EACH_VEC_SAFE_ELT (args, ix, t)
   11400     35330058 :     CALL_EXPR_ARG (ret, ix) = t;
   11401     46689642 :   process_call_operands (ret);
   11402     46689642 :   return ret;
   11403              : }
   11404              : 
   11405              : /* Conveniently construct a function call expression.  FNDECL names the
   11406              :    function to be called and N arguments are passed in the array
   11407              :    ARGARRAY.  */
   11408              : 
   11409              : tree
   11410     23925506 : build_call_expr_loc_array (location_t loc, tree fndecl, int n, tree *argarray)
   11411              : {
   11412     23925506 :   tree fntype = TREE_TYPE (fndecl);
   11413     23925506 :   tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl);
   11414              : 
   11415     23925506 :   return fold_build_call_array_loc (loc, TREE_TYPE (fntype), fn, n, argarray);
   11416              : }
   11417              : 
   11418              : /* Conveniently construct a function call expression.  FNDECL names the
   11419              :    function to be called and the arguments are passed in the vector
   11420              :    VEC.  */
   11421              : 
   11422              : tree
   11423        20975 : build_call_expr_loc_vec (location_t loc, tree fndecl, vec<tree, va_gc> *vec)
   11424              : {
   11425        20975 :   return build_call_expr_loc_array (loc, fndecl, vec_safe_length (vec),
   11426        20975 :                                     vec_safe_address (vec));
   11427              : }
   11428              : 
   11429              : 
   11430              : /* Conveniently construct a function call expression.  FNDECL names the
   11431              :    function to be called, N is the number of arguments, and the "..."
   11432              :    parameters are the argument expressions.  */
   11433              : 
   11434              : tree
   11435     21831194 : build_call_expr_loc (location_t loc, tree fndecl, int n, ...)
   11436              : {
   11437     21831194 :   va_list ap;
   11438     21831194 :   tree *argarray = XALLOCAVEC (tree, n);
   11439     21831194 :   int i;
   11440              : 
   11441     21831194 :   va_start (ap, n);
   11442     24791258 :   for (i = 0; i < n; i++)
   11443      2960064 :     argarray[i] = va_arg (ap, tree);
   11444     21831194 :   va_end (ap);
   11445     21831194 :   return build_call_expr_loc_array (loc, fndecl, n, argarray);
   11446              : }
   11447              : 
   11448              : /* Like build_call_expr_loc (UNKNOWN_LOCATION, ...).  Duplicated because
   11449              :    varargs macros aren't supported by all bootstrap compilers.  */
   11450              : 
   11451              : tree
   11452      2068824 : build_call_expr (tree fndecl, int n, ...)
   11453              : {
   11454      2068824 :   va_list ap;
   11455      2068824 :   tree *argarray = XALLOCAVEC (tree, n);
   11456      2068824 :   int i;
   11457              : 
   11458      2068824 :   va_start (ap, n);
   11459      6201078 :   for (i = 0; i < n; i++)
   11460      4132254 :     argarray[i] = va_arg (ap, tree);
   11461      2068824 :   va_end (ap);
   11462      2068824 :   return build_call_expr_loc_array (UNKNOWN_LOCATION, fndecl, n, argarray);
   11463              : }
   11464              : 
   11465              : /* Build an internal call to IFN, with arguments ARGS[0:N-1] and with return
   11466              :    type TYPE.  This is just like CALL_EXPR, except its CALL_EXPR_FN is NULL.
   11467              :    It will get gimplified later into an ordinary internal function.  */
   11468              : 
   11469              : tree
   11470       813752 : build_call_expr_internal_loc_array (location_t loc, internal_fn ifn,
   11471              :                                     tree type, int n, const tree *args)
   11472              : {
   11473       813752 :   tree t = build_call_1 (type, NULL_TREE, n);
   11474      3393745 :   for (int i = 0; i < n; ++i)
   11475      1766241 :     CALL_EXPR_ARG (t, i) = args[i];
   11476       813752 :   SET_EXPR_LOCATION (t, loc);
   11477       813752 :   CALL_EXPR_IFN (t) = ifn;
   11478       813752 :   process_call_operands (t);
   11479       813752 :   return t;
   11480              : }
   11481              : 
   11482              : /* Build internal call expression.  This is just like CALL_EXPR, except
   11483              :    its CALL_EXPR_FN is NULL.  It will get gimplified later into ordinary
   11484              :    internal function.  */
   11485              : 
   11486              : tree
   11487       812445 : build_call_expr_internal_loc (location_t loc, enum internal_fn ifn,
   11488              :                               tree type, int n, ...)
   11489              : {
   11490       812445 :   va_list ap;
   11491       812445 :   tree *argarray = XALLOCAVEC (tree, n);
   11492       812445 :   int i;
   11493              : 
   11494       812445 :   va_start (ap, n);
   11495      2576061 :   for (i = 0; i < n; i++)
   11496      1763616 :     argarray[i] = va_arg (ap, tree);
   11497       812445 :   va_end (ap);
   11498       812445 :   return build_call_expr_internal_loc_array (loc, ifn, type, n, argarray);
   11499              : }
   11500              : 
   11501              : /* Return a function call to FN, if the target is guaranteed to support it,
   11502              :    or null otherwise.
   11503              : 
   11504              :    N is the number of arguments, passed in the "...", and TYPE is the
   11505              :    type of the return value.  */
   11506              : 
   11507              : tree
   11508         1992 : maybe_build_call_expr_loc (location_t loc, combined_fn fn, tree type,
   11509              :                            int n, ...)
   11510              : {
   11511         1992 :   va_list ap;
   11512         1992 :   tree *argarray = XALLOCAVEC (tree, n);
   11513         1992 :   int i;
   11514              : 
   11515         1992 :   va_start (ap, n);
   11516         5219 :   for (i = 0; i < n; i++)
   11517         3227 :     argarray[i] = va_arg (ap, tree);
   11518         1992 :   va_end (ap);
   11519         1992 :   if (internal_fn_p (fn))
   11520              :     {
   11521         1166 :       internal_fn ifn = as_internal_fn (fn);
   11522         1166 :       if (direct_internal_fn_p (ifn))
   11523              :         {
   11524            3 :           tree_pair types = direct_internal_fn_types (ifn, type, argarray);
   11525            3 :           if (!direct_internal_fn_supported_p (ifn, types,
   11526              :                                                OPTIMIZE_FOR_BOTH))
   11527            1 :             return NULL_TREE;
   11528              :         }
   11529         1165 :       return build_call_expr_internal_loc_array (loc, ifn, type, n, argarray);
   11530              :     }
   11531              :   else
   11532              :     {
   11533          826 :       tree fndecl = builtin_decl_implicit (as_builtin_fn (fn));
   11534          826 :       if (!fndecl)
   11535              :         return NULL_TREE;
   11536          718 :       return build_call_expr_loc_array (loc, fndecl, n, argarray);
   11537              :     }
   11538              : }
   11539              : 
   11540              : /* Return a function call to the appropriate builtin alloca variant.
   11541              : 
   11542              :    SIZE is the size to be allocated.  ALIGN, if non-zero, is the requested
   11543              :    alignment of the allocated area.  MAX_SIZE, if non-negative, is an upper
   11544              :    bound for SIZE in case it is not a fixed value.  */
   11545              : 
   11546              : tree
   11547         9041 : build_alloca_call_expr (tree size, unsigned int align, HOST_WIDE_INT max_size)
   11548              : {
   11549         9041 :   if (max_size >= 0)
   11550              :     {
   11551            0 :       tree t = builtin_decl_explicit (BUILT_IN_ALLOCA_WITH_ALIGN_AND_MAX);
   11552            0 :       return
   11553            0 :         build_call_expr (t, 3, size, size_int (align), size_int (max_size));
   11554              :     }
   11555         9041 :   else if (align > 0)
   11556              :     {
   11557         9041 :       tree t = builtin_decl_explicit (BUILT_IN_ALLOCA_WITH_ALIGN);
   11558         9041 :       return build_call_expr (t, 2, size, size_int (align));
   11559              :     }
   11560              :   else
   11561              :     {
   11562            0 :       tree t = builtin_decl_explicit (BUILT_IN_ALLOCA);
   11563            0 :       return build_call_expr (t, 1, size);
   11564              :     }
   11565              : }
   11566              : 
   11567              : /* The built-in decl to use to mark code points believed to be unreachable.
   11568              :    Typically __builtin_unreachable, but __builtin_trap if
   11569              :    -fsanitize=unreachable -fsanitize-trap=unreachable.  If only
   11570              :    -fsanitize=unreachable, we rely on sanopt to replace calls with the
   11571              :    appropriate ubsan function.  When building a call directly, use
   11572              :    {gimple_},build_builtin_unreachable instead.  */
   11573              : 
   11574              : tree
   11575       351130 : builtin_decl_unreachable ()
   11576              : {
   11577       351130 :   enum built_in_function fncode = BUILT_IN_UNREACHABLE;
   11578              : 
   11579       702260 :   if (sanitize_flags_p (SANITIZE_UNREACHABLE)
   11580       351130 :       ? (flag_sanitize_trap & SANITIZE_UNREACHABLE)
   11581       350532 :       : flag_unreachable_traps)
   11582           22 :     fncode = BUILT_IN_UNREACHABLE_TRAP;
   11583              :   /* For non-trapping sanitize, we will rewrite __builtin_unreachable () later,
   11584              :      in the sanopt pass.  */
   11585              : 
   11586       351130 :   return builtin_decl_explicit (fncode);
   11587              : }
   11588              : 
   11589              : /* Build a call to __builtin_unreachable, possibly rewritten by
   11590              :    -fsanitize=unreachable.  Use this rather than the above when practical.  */
   11591              : 
   11592              : tree
   11593     20295434 : build_builtin_unreachable (location_t loc)
   11594              : {
   11595     20295434 :   tree data = NULL_TREE;
   11596     20295434 :   tree fn = sanitize_unreachable_fn (&data, loc);
   11597     20295434 :   return build_call_expr_loc (loc, fn, data != NULL_TREE, data);
   11598              : }
   11599              : 
   11600              : /* Create a new constant string literal of type ELTYPE[SIZE] (or LEN
   11601              :    if SIZE == -1) and return a tree node representing char* pointer to
   11602              :    it as an ADDR_EXPR (ARRAY_REF (ELTYPE, ...)).  When STR is nonnull
   11603              :    the STRING_CST value is the LEN bytes at STR (the representation
   11604              :    of the string, which may be wide).  Otherwise it's all zeros.  */
   11605              : 
   11606              : tree
   11607       272619 : build_string_literal (unsigned len, const char *str /* = NULL */,
   11608              :                       tree eltype /* = char_type_node */,
   11609              :                       unsigned HOST_WIDE_INT size /* = -1 */)
   11610              : {
   11611       272619 :   tree t = build_string (len, str);
   11612              :   /* Set the maximum valid index based on the string length or SIZE.  */
   11613       545238 :   unsigned HOST_WIDE_INT maxidx
   11614       272619 :     = (size == HOST_WIDE_INT_M1U ? len : size) - 1;
   11615              : 
   11616       272619 :   tree index = build_index_type (size_int (maxidx));
   11617       272619 :   eltype = build_type_variant (eltype, 1, 0);
   11618       272619 :   tree type = build_array_type (eltype, index);
   11619       272619 :   TREE_TYPE (t) = type;
   11620       272619 :   TREE_CONSTANT (t) = 1;
   11621       272619 :   TREE_READONLY (t) = 1;
   11622       272619 :   TREE_STATIC (t) = 1;
   11623              : 
   11624       272619 :   type = build_pointer_type (eltype);
   11625       272619 :   t = build1 (ADDR_EXPR, type,
   11626              :               build4 (ARRAY_REF, eltype,
   11627              :                       t, integer_zero_node, NULL_TREE, NULL_TREE));
   11628       272619 :   return t;
   11629              : }
   11630              : 
   11631              : 
   11632              : 
   11633              : /* Return true if T (assumed to be a DECL) must be assigned a memory
   11634              :    location.  */
   11635              : 
   11636              : bool
   11637   2030169425 : needs_to_live_in_memory (const_tree t)
   11638              : {
   11639   2030169425 :   return (TREE_ADDRESSABLE (t)
   11640   1649465849 :           || is_global_var (t)
   11641   3222485813 :           || (TREE_CODE (t) == RESULT_DECL
   11642      8462443 :               && !DECL_BY_REFERENCE (t)
   11643      5938969 :               && aggregate_value_p (t, current_function_decl)));
   11644              : }
   11645              : 
   11646              : /* Return value of a constant X and sign-extend it.  */
   11647              : 
   11648              : HOST_WIDE_INT
   11649    771752871 : int_cst_value (const_tree x)
   11650              : {
   11651    771752871 :   unsigned bits = TYPE_PRECISION (TREE_TYPE (x));
   11652    771752871 :   unsigned HOST_WIDE_INT val = TREE_INT_CST_LOW (x);
   11653              : 
   11654              :   /* Make sure the sign-extended value will fit in a HOST_WIDE_INT.  */
   11655    771752871 :   gcc_assert (cst_and_fits_in_hwi (x));
   11656              : 
   11657    771752871 :   if (bits < HOST_BITS_PER_WIDE_INT)
   11658              :     {
   11659    757014185 :       bool negative = ((val >> (bits - 1)) & 1) != 0;
   11660    757014185 :       if (negative)
   11661       211231 :         val |= HOST_WIDE_INT_M1U << (bits - 1) << 1;
   11662              :       else
   11663    756802954 :         val &= ~(HOST_WIDE_INT_M1U << (bits - 1) << 1);
   11664              :     }
   11665              : 
   11666    771752871 :   return val;
   11667              : }
   11668              : 
   11669              : /* If TYPE is an integral or pointer type, return an integer type with
   11670              :    the same precision which is unsigned iff UNSIGNEDP is true, or itself
   11671              :    if TYPE is already an integer type of signedness UNSIGNEDP.
   11672              :    If TYPE is a floating-point type, return an integer type with the same
   11673              :    bitsize and with the signedness given by UNSIGNEDP; this is useful
   11674              :    when doing bit-level operations on a floating-point value.  */
   11675              : 
   11676              : tree
   11677     90520659 : signed_or_unsigned_type_for (int unsignedp, tree type)
   11678              : {
   11679     90520659 :   if (ANY_INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) == unsignedp)
   11680              :     return type;
   11681              : 
   11682     57913175 :   if (TREE_CODE (type) == VECTOR_TYPE)
   11683              :     {
   11684        27579 :       tree inner = TREE_TYPE (type);
   11685        27579 :       tree inner2 = signed_or_unsigned_type_for (unsignedp, inner);
   11686        27579 :       if (!inner2)
   11687              :         return NULL_TREE;
   11688        27579 :       if (inner == inner2)
   11689              :         return type;
   11690        27579 :       machine_mode new_mode;
   11691        55158 :       if (VECTOR_MODE_P (TYPE_MODE (type))
   11692        55074 :           && related_int_vector_mode (TYPE_MODE (type)).exists (&new_mode))
   11693        27495 :         return build_vector_type_for_mode (inner2, new_mode);
   11694           84 :       return build_vector_type (inner2, TYPE_VECTOR_SUBPARTS (type));
   11695              :     }
   11696              : 
   11697              :   if (TREE_CODE (type) == COMPLEX_TYPE)
   11698              :     {
   11699           24 :       tree inner = TREE_TYPE (type);
   11700           24 :       tree inner2 = signed_or_unsigned_type_for (unsignedp, inner);
   11701           24 :       if (!inner2)
   11702              :         return NULL_TREE;
   11703           24 :       if (inner == inner2)
   11704              :         return type;
   11705           24 :       return build_complex_type (inner2);
   11706              :     }
   11707              : 
   11708              :   unsigned int bits;
   11709              :   if (INTEGRAL_TYPE_P (type)
   11710              :       || POINTER_TYPE_P (type)
   11711              :       || TREE_CODE (type) == OFFSET_TYPE)
   11712     57885478 :     bits = TYPE_PRECISION (type);
   11713              :   else if (TREE_CODE (type) == REAL_TYPE)
   11714          188 :     bits = GET_MODE_BITSIZE (SCALAR_TYPE_MODE (type));
   11715              :   else
   11716              :     return NULL_TREE;
   11717              : 
   11718     57885572 :   if (TREE_CODE (type) == BITINT_TYPE)
   11719         2989 :     return build_bitint_type (bits, unsignedp);
   11720     57882583 :   return build_nonstandard_integer_type (bits, unsignedp);
   11721              : }
   11722              : 
   11723              : /* If TYPE is an integral or pointer type, return an integer type with
   11724              :    the same precision which is unsigned, or itself if TYPE is already an
   11725              :    unsigned integer type.  If TYPE is a floating-point type, return an
   11726              :    unsigned integer type with the same bitsize as TYPE.  */
   11727              : 
   11728              : tree
   11729     80309398 : unsigned_type_for (tree type)
   11730              : {
   11731     80309398 :   return signed_or_unsigned_type_for (1, type);
   11732              : }
   11733              : 
   11734              : /* If TYPE is an integral or pointer type, return an integer type with
   11735              :    the same precision which is signed, or itself if TYPE is already a
   11736              :    signed integer type.  If TYPE is a floating-point type, return a
   11737              :    signed integer type with the same bitsize as TYPE.  */
   11738              : 
   11739              : tree
   11740     10006442 : signed_type_for (tree type)
   11741              : {
   11742     10006442 :   return signed_or_unsigned_type_for (0, type);
   11743              : }
   11744              : 
   11745              : /* - For VECTOR_TYPEs:
   11746              :     - The truth type must be a VECTOR_BOOLEAN_TYPE.
   11747              :     - The number of elements must match (known_eq).
   11748              :     - targetm.vectorize.get_mask_mode exists, and exactly
   11749              :       the same mode as the truth type.
   11750              :    - Otherwise, the truth type must be a BOOLEAN_TYPE
   11751              :      or useless_type_conversion_p to BOOLEAN_TYPE.  */
   11752              : bool
   11753         1374 : is_truth_type_for (tree type, tree truth_type)
   11754              : {
   11755         1374 :   machine_mode mask_mode = TYPE_MODE (truth_type);
   11756         1374 :   machine_mode vmode = TYPE_MODE (type);
   11757         1374 :   machine_mode tmask_mode;
   11758              : 
   11759         1374 :   if (TREE_CODE (type) == VECTOR_TYPE)
   11760              :     {
   11761         1374 :       if (VECTOR_BOOLEAN_TYPE_P (truth_type)
   11762         1374 :           && known_eq (TYPE_VECTOR_SUBPARTS (type),
   11763              :                        TYPE_VECTOR_SUBPARTS (truth_type))
   11764         1374 :           && targetm.vectorize.get_mask_mode (vmode).exists (&tmask_mode)
   11765         2748 :           && tmask_mode == mask_mode)
   11766         1355 :         return true;
   11767              : 
   11768           19 :       return false;
   11769              :     }
   11770              : 
   11771            0 :   return useless_type_conversion_p (boolean_type_node, truth_type);
   11772              : }
   11773              : 
   11774              : /* If TYPE is a vector type, return a signed integer vector type with the
   11775              :    same width and number of subparts. Otherwise return boolean_type_node.  */
   11776              : 
   11777              : tree
   11778      3746378 : truth_type_for (tree type)
   11779              : {
   11780      3746378 :   if (TREE_CODE (type) == VECTOR_TYPE)
   11781              :     {
   11782      2706419 :       if (VECTOR_BOOLEAN_TYPE_P (type))
   11783              :         return type;
   11784      2647091 :       return build_truth_vector_type_for (type);
   11785              :     }
   11786              :   else
   11787      1039959 :     return boolean_type_node;
   11788              : }
   11789              : 
   11790              : /* Returns the largest value obtainable by casting something in INNER type to
   11791              :    OUTER type.  */
   11792              : 
   11793              : tree
   11794     11263814 : upper_bound_in_type (tree outer, tree inner)
   11795              : {
   11796     11263814 :   unsigned int det = 0;
   11797     11263814 :   unsigned oprec = TYPE_PRECISION (outer);
   11798     11263814 :   unsigned iprec = TYPE_PRECISION (inner);
   11799     11263814 :   unsigned prec;
   11800              : 
   11801              :   /* Compute a unique number for every combination.  */
   11802     11263814 :   det |= (oprec > iprec) ? 4 : 0;
   11803     11263814 :   det |= TYPE_UNSIGNED (outer) ? 2 : 0;
   11804     11263814 :   det |= TYPE_UNSIGNED (inner) ? 1 : 0;
   11805              : 
   11806              :   /* Determine the exponent to use.  */
   11807     11263814 :   switch (det)
   11808              :     {
   11809      7560329 :     case 0:
   11810      7560329 :     case 1:
   11811              :       /* oprec <= iprec, outer: signed, inner: don't care.  */
   11812      7560329 :       prec = oprec - 1;
   11813      7560329 :       break;
   11814              :     case 2:
   11815              :     case 3:
   11816              :       /* oprec <= iprec, outer: unsigned, inner: don't care.  */
   11817              :       prec = oprec;
   11818              :       break;
   11819        22621 :     case 4:
   11820              :       /* oprec > iprec, outer: signed, inner: signed.  */
   11821        22621 :       prec = iprec - 1;
   11822        22621 :       break;
   11823              :     case 5:
   11824              :       /* oprec > iprec, outer: signed, inner: unsigned.  */
   11825         9531 :       prec = iprec;
   11826              :       break;
   11827              :     case 6:
   11828              :       /* oprec > iprec, outer: unsigned, inner: signed.  */
   11829              :       prec = oprec;
   11830              :       break;
   11831              :     case 7:
   11832              :       /* oprec > iprec, outer: unsigned, inner: unsigned.  */
   11833         9531 :       prec = iprec;
   11834              :       break;
   11835              :     default:
   11836              :       gcc_unreachable ();
   11837              :     }
   11838              : 
   11839     11263814 :   return wide_int_to_tree (outer,
   11840     11263814 :                            wi::mask (prec, false, TYPE_PRECISION (outer)));
   11841              : }
   11842              : 
   11843              : /* Returns the smallest value obtainable by casting something in INNER type to
   11844              :    OUTER type.  */
   11845              : 
   11846              : tree
   11847      8612884 : lower_bound_in_type (tree outer, tree inner)
   11848              : {
   11849      8612884 :   unsigned oprec = TYPE_PRECISION (outer);
   11850      8612884 :   unsigned iprec = TYPE_PRECISION (inner);
   11851              : 
   11852              :   /* If OUTER type is unsigned, we can definitely cast 0 to OUTER type
   11853              :      and obtain 0.  */
   11854      8612884 :   if (TYPE_UNSIGNED (outer)
   11855              :       /* If we are widening something of an unsigned type, OUTER type
   11856              :          contains all values of INNER type.  In particular, both INNER
   11857              :          and OUTER types have zero in common.  */
   11858      8612884 :       || (oprec > iprec && TYPE_UNSIGNED (inner)))
   11859      2295108 :     return build_int_cst (outer, 0);
   11860              :   else
   11861              :     {
   11862              :       /* If we are widening a signed type to another signed type, we
   11863              :          want to obtain -2^^(iprec-1).  If we are keeping the
   11864              :          precision or narrowing to a signed type, we want to obtain
   11865              :          -2^(oprec-1).  */
   11866      6317776 :       unsigned prec = oprec > iprec ? iprec : oprec;
   11867      6317776 :       return wide_int_to_tree (outer,
   11868     12635552 :                                wi::mask (prec - 1, true,
   11869      6317776 :                                          TYPE_PRECISION (outer)));
   11870              :     }
   11871              : }
   11872              : 
   11873              : /* Return true if two operands that are suitable for PHI nodes are
   11874              :    necessarily equal.  Specifically, both ARG0 and ARG1 must be either
   11875              :    SSA_NAME or invariant.  Note that this is strictly an optimization.
   11876              :    That is, callers of this function can directly call operand_equal_p
   11877              :    and get the same result, only slower.  */
   11878              : 
   11879              : bool
   11880     22068184 : operand_equal_for_phi_arg_p (const_tree arg0, const_tree arg1)
   11881              : {
   11882     22068184 :   if (arg0 == arg1)
   11883              :     return true;
   11884     20288240 :   if (TREE_CODE (arg0) == SSA_NAME || TREE_CODE (arg1) == SSA_NAME)
   11885              :     return false;
   11886      4401166 :   return operand_equal_p (arg0, arg1, 0);
   11887              : }
   11888              : 
   11889              : /* Returns number of zeros at the end of binary representation of X.  */
   11890              : 
   11891              : tree
   11892      9402203 : num_ending_zeros (const_tree x)
   11893              : {
   11894      9402203 :   return build_int_cst (TREE_TYPE (x), wi::ctz (wi::to_wide (x)));
   11895              : }
   11896              : 
   11897              : 
   11898              : #define WALK_SUBTREE(NODE)                              \
   11899              :   do                                                    \
   11900              :     {                                                   \
   11901              :       result = walk_tree_1 (&(NODE), func, data, pset, lh); \
   11902              :       if (result)                                       \
   11903              :         return result;                                  \
   11904              :     }                                                   \
   11905              :   while (0)
   11906              : 
   11907              : /* This is a subroutine of walk_tree that walks field of TYPE that are to
   11908              :    be walked whenever a type is seen in the tree.  Rest of operands and return
   11909              :    value are as for walk_tree.  */
   11910              : 
   11911              : static tree
   11912   5190173804 : walk_type_fields (tree type, walk_tree_fn func, void *data,
   11913              :                   hash_set<tree> *pset, walk_tree_lh lh)
   11914              : {
   11915   5190173804 :   tree result = NULL_TREE;
   11916              : 
   11917   5190173804 :   switch (TREE_CODE (type))
   11918              :     {
   11919   1510580088 :     case POINTER_TYPE:
   11920   1510580088 :     case REFERENCE_TYPE:
   11921   1510580088 :     case VECTOR_TYPE:
   11922              :       /* We have to worry about mutually recursive pointers.  These can't
   11923              :          be written in C.  They can in Ada.  It's pathological, but
   11924              :          there's an ACATS test (c38102a) that checks it.  Deal with this
   11925              :          by checking if we're pointing to another pointer, that one
   11926              :          points to another pointer, that one does too, and we have no htab.
   11927              :          If so, get a hash table.  We check three levels deep to avoid
   11928              :          the cost of the hash table if we don't need one.  */
   11929   2971433481 :       if (POINTER_TYPE_P (TREE_TYPE (type))
   11930     49726764 :           && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (type)))
   11931      7329698 :           && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (TREE_TYPE (type))))
   11932   1517808370 :           && !pset)
   11933              :         {
   11934            0 :           result = walk_tree_without_duplicates (&TREE_TYPE (type),
   11935              :                                                  func, data);
   11936            0 :           if (result)
   11937              :             return result;
   11938              : 
   11939              :           break;
   11940              :         }
   11941              : 
   11942              :       /* fall through */
   11943              : 
   11944   1513538066 :     case COMPLEX_TYPE:
   11945   1513538066 :       WALK_SUBTREE (TREE_TYPE (type));
   11946              :       break;
   11947              : 
   11948    264570290 :     case METHOD_TYPE:
   11949    264570290 :       WALK_SUBTREE (TYPE_METHOD_BASETYPE (type));
   11950              : 
   11951              :       /* Fall through.  */
   11952              : 
   11953    432420424 :     case FUNCTION_TYPE:
   11954    432420424 :       WALK_SUBTREE (TREE_TYPE (type));
   11955    432420382 :       {
   11956    432420382 :         tree arg;
   11957              : 
   11958              :         /* We never want to walk into default arguments.  */
   11959   1656859938 :         for (arg = TYPE_ARG_TYPES (type); arg; arg = TREE_CHAIN (arg))
   11960   1224468142 :           WALK_SUBTREE (TREE_VALUE (arg));
   11961              :       }
   11962              :       break;
   11963              : 
   11964     16939454 :     case ARRAY_TYPE:
   11965              :       /* Don't follow this nodes's type if a pointer for fear that
   11966              :          we'll have infinite recursion.  If we have a PSET, then we
   11967              :          need not fear.  */
   11968     16939454 :       if (pset
   11969     16939454 :           || (!POINTER_TYPE_P (TREE_TYPE (type))
   11970       163566 :               && TREE_CODE (TREE_TYPE (type)) != OFFSET_TYPE))
   11971     16918700 :         WALK_SUBTREE (TREE_TYPE (type));
   11972     16936829 :       WALK_SUBTREE (TYPE_DOMAIN (type));
   11973              :       break;
   11974              : 
   11975      1121078 :     case OFFSET_TYPE:
   11976      1121078 :       WALK_SUBTREE (TREE_TYPE (type));
   11977      1120192 :       WALK_SUBTREE (TYPE_OFFSET_BASETYPE (type));
   11978              :       break;
   11979              : 
   11980              :     default:
   11981              :       break;
   11982              :     }
   11983              : 
   11984              :   return NULL_TREE;
   11985              : }
   11986              : 
   11987              : /* Apply FUNC to all the sub-trees of TP in a pre-order traversal.  FUNC is
   11988              :    called with the DATA and the address of each sub-tree.  If FUNC returns a
   11989              :    non-NULL value, the traversal is stopped, and the value returned by FUNC
   11990              :    is returned.  If PSET is non-NULL it is used to record the nodes visited,
   11991              :    and to avoid visiting a node more than once.
   11992              :    Note that TREE_PURPOSE is not walked.  */
   11993              : 
   11994              : tree
   11995  >11117*10^7 : walk_tree_1 (tree *tp, walk_tree_fn func, void *data,
   11996              :              hash_set<tree> *pset, walk_tree_lh lh)
   11997              : {
   11998              : #define WALK_SUBTREE_TAIL(NODE)                         \
   11999              :   do                                                    \
   12000              :     {                                                   \
   12001              :        tp = & (NODE);                                       \
   12002              :        goto tail_recurse;                               \
   12003              :     }                                                   \
   12004              :   while (0)
   12005              : 
   12006  26075551160 :  tail_recurse:
   12007              :   /* Skip empty subtrees.  */
   12008  >13725*10^7 :   if (!*tp)
   12009              :     return NULL_TREE;
   12010              : 
   12011              :   /* Don't walk the same tree twice, if the user has requested
   12012              :      that we avoid doing so.  */
   12013  >11347*10^7 :   if (pset && pset->add (*tp))
   12014              :     return NULL_TREE;
   12015              : 
   12016              :   /* Call the function.  */
   12017  >11170*10^7 :   int walk_subtrees = 1;
   12018  >11170*10^7 :   tree result = (*func) (tp, &walk_subtrees, data);
   12019              : 
   12020              :   /* If we found something, return it.  */
   12021  >11170*10^7 :   if (result)
   12022              :     return result;
   12023              : 
   12024  >11163*10^7 :   tree t = *tp;
   12025  >11163*10^7 :   tree_code code = TREE_CODE (t);
   12026              : 
   12027              :   /* Even if we didn't, FUNC may have decided that there was nothing
   12028              :      interesting below this point in the tree.  */
   12029  >11163*10^7 :   if (!walk_subtrees)
   12030              :     {
   12031              :       /* But we still need to check our siblings.  */
   12032  68516359978 :       if (code == TREE_LIST)
   12033       116653 :         WALK_SUBTREE_TAIL (TREE_CHAIN (t));
   12034  68516243325 :       else if (code == OMP_CLAUSE)
   12035       891693 :         WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (t));
   12036              :       else
   12037              :         return NULL_TREE;
   12038              :     }
   12039              : 
   12040  43115175605 :   if (lh)
   12041              :     {
   12042  25260162246 :       result = (*lh) (tp, &walk_subtrees, func, data, pset);
   12043  25260162246 :       if (result || !walk_subtrees)
   12044              :         return result;
   12045              :     }
   12046              : 
   12047  40193788973 :   switch (code)
   12048              :     {
   12049              :     case ERROR_MARK:
   12050              :     case IDENTIFIER_NODE:
   12051              :     case INTEGER_CST:
   12052              :     case REAL_CST:
   12053              :     case FIXED_CST:
   12054              :     case STRING_CST:
   12055              :     case BLOCK:
   12056              :     case PLACEHOLDER_EXPR:
   12057              :     case SSA_NAME:
   12058              :     case FIELD_DECL:
   12059              :     case RESULT_DECL:
   12060              :       /* None of these have subtrees other than those already walked
   12061              :          above.  */
   12062              :       break;
   12063              : 
   12064    286811742 :     case TREE_LIST:
   12065    286811742 :       WALK_SUBTREE (TREE_VALUE (t));
   12066    286328571 :       WALK_SUBTREE_TAIL (TREE_CHAIN (t));
   12067              : 
   12068   1338150397 :     case TREE_VEC:
   12069   1338150397 :       {
   12070   1338150397 :         int len = TREE_VEC_LENGTH (t);
   12071              : 
   12072   1338150397 :         if (len == 0)
   12073              :           break;
   12074              : 
   12075              :         /* Walk all elements but the last.  */
   12076   2456177778 :         for (int i = 0; i < len - 1; ++i)
   12077   1127743498 :           WALK_SUBTREE (TREE_VEC_ELT (t, i));
   12078              : 
   12079              :         /* Now walk the last one as a tail call.  */
   12080   1328434280 :         WALK_SUBTREE_TAIL (TREE_VEC_ELT (t, len - 1));
   12081              :       }
   12082              : 
   12083      5619824 :     case VECTOR_CST:
   12084      5619824 :       {
   12085      5619824 :         unsigned len = vector_cst_encoded_nelts (t);
   12086      5619824 :         if (len == 0)
   12087              :           break;
   12088              :         /* Walk all elements but the last.  */
   12089     18541344 :         for (unsigned i = 0; i < len - 1; ++i)
   12090     12921688 :           WALK_SUBTREE (VECTOR_CST_ENCODED_ELT (t, i));
   12091              :         /* Now walk the last one as a tail call.  */
   12092      5619656 :         WALK_SUBTREE_TAIL (VECTOR_CST_ENCODED_ELT (t, len - 1));
   12093              :       }
   12094              : 
   12095       641738 :     case COMPLEX_CST:
   12096       641738 :       WALK_SUBTREE (TREE_REALPART (t));
   12097       640166 :       WALK_SUBTREE_TAIL (TREE_IMAGPART (t));
   12098              : 
   12099              :     case CONSTRUCTOR:
   12100              :       {
   12101              :         unsigned HOST_WIDE_INT idx;
   12102              :         constructor_elt *ce;
   12103              : 
   12104    972388076 :         for (idx = 0; vec_safe_iterate (CONSTRUCTOR_ELTS (t), idx, &ce);
   12105              :              idx++)
   12106    499961608 :           WALK_SUBTREE (ce->value);
   12107              :       }
   12108              :       break;
   12109              : 
   12110      4827285 :     case SAVE_EXPR:
   12111      4827285 :       WALK_SUBTREE_TAIL (TREE_OPERAND (t, 0));
   12112              : 
   12113    270936878 :     case BIND_EXPR:
   12114    270936878 :       {
   12115    270936878 :         tree decl;
   12116    437438262 :         for (decl = BIND_EXPR_VARS (t); decl; decl = DECL_CHAIN (decl))
   12117              :           {
   12118              :             /* Walk the DECL_INITIAL and DECL_SIZE.  We don't want to walk
   12119              :                into declarations that are just mentioned, rather than
   12120              :                declared; they don't really belong to this part of the tree.
   12121              :                And, we can see cycles: the initializer for a declaration
   12122              :                can refer to the declaration itself.  */
   12123    166501408 :             WALK_SUBTREE (DECL_INITIAL (decl));
   12124    166501384 :             WALK_SUBTREE (DECL_SIZE (decl));
   12125    166501384 :             WALK_SUBTREE (DECL_SIZE_UNIT (decl));
   12126              :           }
   12127    270936854 :         WALK_SUBTREE_TAIL (BIND_EXPR_BODY (t));
   12128              :       }
   12129              : 
   12130    362905020 :     case STATEMENT_LIST:
   12131    362905020 :       {
   12132    362905020 :         tree_stmt_iterator i;
   12133   1306079099 :         for (i = tsi_start (t); !tsi_end_p (i); tsi_next (&i))
   12134    943364708 :           WALK_SUBTREE (*tsi_stmt_ptr (i));
   12135              :       }
   12136    362714391 :       break;
   12137              : 
   12138      1849686 :     case OMP_CLAUSE:
   12139      1849686 :       {
   12140      1849686 :         int len = omp_clause_num_ops[OMP_CLAUSE_CODE (t)];
   12141              :         /* Do not walk the iterator operand of OpenMP MAP clauses.  */
   12142      1849686 :         if (OMP_CLAUSE_HAS_ITERATORS (t))
   12143         1638 :           len--;
   12144      5280667 :         for (int i = 0; i < len; i++)
   12145      3430981 :           WALK_SUBTREE (OMP_CLAUSE_OPERAND (t, i));
   12146      1849686 :         WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (t));
   12147              :       }
   12148              : 
   12149          838 :     case OMP_METADIRECTIVE:
   12150              :       /* Handle this explicitly as TREE_PURPOSE is usually not walked.  */
   12151         2813 :       for (tree t2 = OMP_METADIRECTIVE_VARIANTS (t); t2; t2 = TREE_CHAIN (t2))
   12152              :         {
   12153         1975 :           WALK_SUBTREE (OMP_METADIRECTIVE_VARIANT_SELECTOR (t2));
   12154         1975 :           WALK_SUBTREE (OMP_METADIRECTIVE_VARIANT_DIRECTIVE (t2));
   12155         1975 :           WALK_SUBTREE (OMP_METADIRECTIVE_VARIANT_BODY (t2));
   12156              :         }
   12157              :       break;
   12158              : 
   12159     81794299 :     case TARGET_EXPR:
   12160     81794299 :       {
   12161     81794299 :         int i, len;
   12162              : 
   12163              :         /* TARGET_EXPRs are peculiar: operands 1 and 3 can be the same.
   12164              :            But, we only want to walk once.  */
   12165     81794299 :         len = (TREE_OPERAND (t, 3) == TREE_OPERAND (t, 1)) ? 2 : 3;
   12166    327141643 :         for (i = 0; i < len; ++i)
   12167    245365069 :           WALK_SUBTREE (TREE_OPERAND (t, i));
   12168     81776574 :         WALK_SUBTREE_TAIL (TREE_OPERAND (t, len));
   12169              :       }
   12170              : 
   12171    163213717 :     case DECL_EXPR:
   12172              :       /* If this is a TYPE_DECL, walk into the fields of the type that it's
   12173              :          defining.  We only want to walk into these fields of a type in this
   12174              :          case and not in the general case of a mere reference to the type.
   12175              : 
   12176              :          The criterion is as follows: if the field can be an expression, it
   12177              :          must be walked only here.  This should be in keeping with the fields
   12178              :          that are directly gimplified in gimplify_type_sizes in order for the
   12179              :          mark/copy-if-shared/unmark machinery of the gimplifier to work with
   12180              :          variable-sized types.
   12181              : 
   12182              :          Note that DECLs get walked as part of processing the BIND_EXPR.  */
   12183    163213717 :       if (TREE_CODE (DECL_EXPR_DECL (t)) == TYPE_DECL)
   12184              :         {
   12185              :           /* Call the function for the decl so e.g. copy_tree_body_r can
   12186              :              replace it with the remapped one.  */
   12187      1766791 :           result = (*func) (&DECL_EXPR_DECL (t), &walk_subtrees, data);
   12188      1766791 :           if (result || !walk_subtrees)
   12189              :             return result;
   12190              : 
   12191      1721755 :           tree *type_p = &TREE_TYPE (DECL_EXPR_DECL (t));
   12192      1721755 :           if (TREE_CODE (*type_p) == ERROR_MARK)
   12193              :             return NULL_TREE;
   12194              : 
   12195              :           /* Call the function for the type.  See if it returns anything or
   12196              :              doesn't want us to continue.  If we are to continue, walk both
   12197              :              the normal fields and those for the declaration case.  */
   12198      1721755 :           result = (*func) (type_p, &walk_subtrees, data);
   12199      1721755 :           if (result || !walk_subtrees)
   12200              :             return result;
   12201              : 
   12202      1627288 :           tree type = *type_p;
   12203              : 
   12204              :           /* But do not walk a pointed-to type since it may itself need to
   12205              :              be walked in the declaration case if it isn't anonymous.  */
   12206      1627288 :           if (!POINTER_TYPE_P (type))
   12207              :             {
   12208      1611581 :               result = walk_type_fields (type, func, data, pset, lh);
   12209      1611581 :               if (result)
   12210              :                 return result;
   12211              :             }
   12212              : 
   12213              :           /* If this is a record type, also walk the fields.  */
   12214      1627288 :           if (RECORD_OR_UNION_TYPE_P (type))
   12215              :             {
   12216       502823 :               tree field;
   12217              : 
   12218      2366939 :               for (field = TYPE_FIELDS (type); field;
   12219      1864116 :                    field = DECL_CHAIN (field))
   12220              :                 {
   12221              :                   /* We'd like to look at the type of the field, but we can
   12222              :                      easily get infinite recursion.  So assume it's pointed
   12223              :                      to elsewhere in the tree.  Also, ignore things that
   12224              :                      aren't fields.  */
   12225      1864116 :                   if (TREE_CODE (field) != FIELD_DECL)
   12226      1393577 :                     continue;
   12227              : 
   12228       470539 :                   WALK_SUBTREE (DECL_FIELD_OFFSET (field));
   12229       470539 :                   WALK_SUBTREE (DECL_SIZE (field));
   12230       470539 :                   WALK_SUBTREE (DECL_SIZE_UNIT (field));
   12231       470539 :                   if (TREE_CODE (type) == QUAL_UNION_TYPE)
   12232            0 :                     WALK_SUBTREE (DECL_QUALIFIER (field));
   12233              :                 }
   12234              :             }
   12235              : 
   12236              :           /* Same for scalar types.  */
   12237              :           else if (TREE_CODE (type) == BOOLEAN_TYPE
   12238              :                    || TREE_CODE (type) == ENUMERAL_TYPE
   12239              :                    || TREE_CODE (type) == INTEGER_TYPE
   12240              :                    || TREE_CODE (type) == FIXED_POINT_TYPE
   12241              :                    || TREE_CODE (type) == REAL_TYPE)
   12242              :             {
   12243        37981 :               WALK_SUBTREE (TYPE_MIN_VALUE (type));
   12244        37981 :               WALK_SUBTREE (TYPE_MAX_VALUE (type));
   12245              :             }
   12246              : 
   12247      1627288 :           WALK_SUBTREE (TYPE_SIZE (type));
   12248      1627288 :           WALK_SUBTREE_TAIL (TYPE_SIZE_UNIT (type));
   12249              :         }
   12250              :       /* FALLTHRU */
   12251              : 
   12252  32744389515 :     default:
   12253  32744389515 :       if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code)))
   12254              :         {
   12255  24363364752 :           int i, len;
   12256              : 
   12257              :           /* Walk over all the sub-trees of this operand.  */
   12258  24363364752 :           len = TREE_OPERAND_LENGTH (t);
   12259              : 
   12260              :           /* Go through the subtrees.  We need to do this in forward order so
   12261              :              that the scope of a FOR_EXPR is handled properly.  */
   12262  24363364752 :           if (len)
   12263              :             {
   12264  48903263633 :               for (i = 0; i < len - 1; ++i)
   12265  24810761179 :                 WALK_SUBTREE (TREE_OPERAND (t, i));
   12266  24092502454 :               WALK_SUBTREE_TAIL (TREE_OPERAND (t, len - 1));
   12267              :             }
   12268              :         }
   12269              :       /* If this is a type, walk the needed fields in the type.  */
   12270   8381024763 :       else if (TYPE_P (t))
   12271   5188562223 :         return walk_type_fields (t, func, data, pset, lh);
   12272              :       break;
   12273              :     }
   12274              : 
   12275              :   /* We didn't find what we were looking for.  */
   12276              :   return NULL_TREE;
   12277              : 
   12278              : #undef WALK_SUBTREE_TAIL
   12279              : }
   12280              : #undef WALK_SUBTREE
   12281              : 
   12282              : /* Like walk_tree, but does not walk duplicate nodes more than once.  */
   12283              : 
   12284              : tree
   12285   3877209546 : walk_tree_without_duplicates_1 (tree *tp, walk_tree_fn func, void *data,
   12286              :                                 walk_tree_lh lh)
   12287              : {
   12288   3877209546 :   tree result;
   12289              : 
   12290   3877209546 :   hash_set<tree> pset;
   12291   3877209546 :   result = walk_tree_1 (tp, func, data, &pset, lh);
   12292   3877209546 :   return result;
   12293   3877209546 : }
   12294              : 
   12295              : 
   12296              : tree
   12297   1196894121 : tree_block (tree t)
   12298              : {
   12299   1196894121 :   const enum tree_code_class c = TREE_CODE_CLASS (TREE_CODE (t));
   12300              : 
   12301   1196894121 :   if (IS_EXPR_CODE_CLASS (c))
   12302   1196894121 :     return LOCATION_BLOCK (t->exp.locus);
   12303            0 :   gcc_unreachable ();
   12304              :   return NULL;
   12305              : }
   12306              : 
   12307              : void
   12308    747797510 : tree_set_block (tree t, tree b)
   12309              : {
   12310    747797510 :   const enum tree_code_class c = TREE_CODE_CLASS (TREE_CODE (t));
   12311              : 
   12312    747797510 :   if (IS_EXPR_CODE_CLASS (c))
   12313              :     {
   12314    747797510 :       t->exp.locus = set_block (t->exp.locus, b);
   12315              :     }
   12316              :   else
   12317            0 :     gcc_unreachable ();
   12318    747797510 : }
   12319              : 
   12320              : /* Create a nameless artificial label and put it in the current
   12321              :    function context.  The label has a location of LOC.  Returns the
   12322              :    newly created label.  */
   12323              : 
   12324              : tree
   12325     33144097 : create_artificial_label (location_t loc)
   12326              : {
   12327     33144097 :   tree lab = build_decl (loc,
   12328              :                          LABEL_DECL, NULL_TREE, void_type_node);
   12329              : 
   12330     33144097 :   DECL_ARTIFICIAL (lab) = 1;
   12331     33144097 :   DECL_IGNORED_P (lab) = 1;
   12332     33144097 :   DECL_CONTEXT (lab) = current_function_decl;
   12333     33144097 :   return lab;
   12334              : }
   12335              : 
   12336              : /*  Given a tree, try to return a useful variable name that we can use
   12337              :     to prefix a temporary that is being assigned the value of the tree.
   12338              :     I.E. given  <temp> = &A, return A.  */
   12339              : 
   12340              : const char *
   12341     25527794 : get_name (tree t)
   12342              : {
   12343     27418988 :   tree stripped_decl;
   12344              : 
   12345     27418988 :   stripped_decl = t;
   12346     27418988 :   STRIP_NOPS (stripped_decl);
   12347     27418988 :   if (DECL_P (stripped_decl) && DECL_NAME (stripped_decl))
   12348      4098543 :     return IDENTIFIER_POINTER (DECL_NAME (stripped_decl));
   12349     23320445 :   else if (TREE_CODE (stripped_decl) == SSA_NAME)
   12350              :     {
   12351      1385801 :       tree name = SSA_NAME_IDENTIFIER (stripped_decl);
   12352       326321 :       if (!name)
   12353              :         return NULL;
   12354       325086 :       return IDENTIFIER_POINTER (name);
   12355              :     }
   12356              :   else
   12357              :     {
   12358     21934644 :       switch (TREE_CODE (stripped_decl))
   12359              :         {
   12360      1891194 :         case ADDR_EXPR:
   12361      1891194 :           return get_name (TREE_OPERAND (stripped_decl, 0));
   12362              :         default:
   12363              :           return NULL;
   12364              :         }
   12365              :     }
   12366              : }
   12367              : 
   12368              : /* Return true if TYPE has a variable argument list.  */
   12369              : 
   12370              : bool
   12371    237286310 : stdarg_p (const_tree fntype)
   12372              : {
   12373    237286310 :   function_args_iterator args_iter;
   12374    237286310 :   tree n = NULL_TREE, t;
   12375              : 
   12376    237286310 :   if (!fntype)
   12377              :     return false;
   12378              : 
   12379    237148735 :   if (TYPE_NO_NAMED_ARGS_STDARG_P (fntype))
   12380              :     return true;
   12381              : 
   12382    960789387 :   FOREACH_FUNCTION_ARGS (fntype, t, args_iter)
   12383              :     {
   12384    724429073 :       n = t;
   12385              :     }
   12386              : 
   12387    236360314 :   return n != NULL_TREE && n != void_type_node;
   12388              : }
   12389              : 
   12390              : /* Return true if TYPE has a prototype.  */
   12391              : 
   12392              : bool
   12393    736265769 : prototype_p (const_tree fntype)
   12394              : {
   12395    736265769 :   tree t;
   12396              : 
   12397    736265769 :   gcc_assert (fntype != NULL_TREE);
   12398              : 
   12399    736265769 :   if (TYPE_NO_NAMED_ARGS_STDARG_P (fntype))
   12400              :     return true;
   12401              : 
   12402    735371779 :   t = TYPE_ARG_TYPES (fntype);
   12403    735371779 :   return (t != NULL_TREE);
   12404              : }
   12405              : 
   12406              : /* If BLOCK is inlined from an __attribute__((__artificial__))
   12407              :    routine, return pointer to location from where it has been
   12408              :    called.  */
   12409              : location_t *
   12410       170655 : block_nonartificial_location (tree block)
   12411              : {
   12412       170655 :   location_t *ret = NULL;
   12413              : 
   12414       435568 :   while (block && TREE_CODE (block) == BLOCK
   12415       524494 :          && BLOCK_ABSTRACT_ORIGIN (block))
   12416              :     {
   12417       161149 :       tree ao = BLOCK_ABSTRACT_ORIGIN (block);
   12418       161149 :       if (TREE_CODE (ao) == FUNCTION_DECL)
   12419              :         {
   12420              :           /* If AO is an artificial inline, point RET to the
   12421              :              call site locus at which it has been inlined and continue
   12422              :              the loop, in case AO's caller is also an artificial
   12423              :              inline.  */
   12424        68646 :           if (DECL_DECLARED_INLINE_P (ao)
   12425        68646 :               && lookup_attribute ("artificial", DECL_ATTRIBUTES (ao)))
   12426         1801 :             ret = &BLOCK_SOURCE_LOCATION (block);
   12427              :           else
   12428              :             break;
   12429              :         }
   12430        92503 :       else if (TREE_CODE (ao) != BLOCK)
   12431              :         break;
   12432              : 
   12433        94304 :       block = BLOCK_SUPERCONTEXT (block);
   12434              :     }
   12435       170655 :   return ret;
   12436              : }
   12437              : 
   12438              : 
   12439              : /* If EXP is inlined from an __attribute__((__artificial__))
   12440              :    function, return the location of the original call expression.  */
   12441              : 
   12442              : location_t
   12443           46 : tree_nonartificial_location (tree exp)
   12444              : {
   12445           46 :   location_t *loc = block_nonartificial_location (TREE_BLOCK (exp));
   12446              : 
   12447           46 :   if (loc)
   12448            0 :     return *loc;
   12449              :   else
   12450           46 :     return EXPR_LOCATION (exp);
   12451              : }
   12452              : 
   12453              : /* Return the location into which EXP has been inlined.  Analogous
   12454              :    to tree_nonartificial_location() above but not limited to artificial
   12455              :    functions declared inline.  If SYSTEM_HEADER is true, return
   12456              :    the macro expansion point of the location if it's in a system header */
   12457              : 
   12458              : location_t
   12459            0 : tree_inlined_location (tree exp, bool system_header /* = true */)
   12460              : {
   12461            0 :   location_t loc = UNKNOWN_LOCATION;
   12462              : 
   12463            0 :   tree block = TREE_BLOCK (exp);
   12464              : 
   12465            0 :   while (block && TREE_CODE (block) == BLOCK
   12466            0 :          && BLOCK_ABSTRACT_ORIGIN (block))
   12467              :     {
   12468            0 :       tree ao = BLOCK_ABSTRACT_ORIGIN (block);
   12469            0 :       if (TREE_CODE (ao) == FUNCTION_DECL)
   12470            0 :         loc = BLOCK_SOURCE_LOCATION (block);
   12471            0 :       else if (TREE_CODE (ao) != BLOCK)
   12472              :         break;
   12473              : 
   12474            0 :       block = BLOCK_SUPERCONTEXT (block);
   12475              :     }
   12476              : 
   12477            0 :   if (loc == UNKNOWN_LOCATION)
   12478              :     {
   12479            0 :       loc = EXPR_LOCATION (exp);
   12480            0 :       if (system_header)
   12481              :         /* Only consider macro expansion when the block traversal failed
   12482              :            to find a location.  Otherwise it's not relevant.  */
   12483            0 :         return expansion_point_location_if_in_system_header (loc);
   12484              :     }
   12485              : 
   12486              :   return loc;
   12487              : }
   12488              : 
   12489              : /* These are the hash table functions for the hash table of OPTIMIZATION_NODE
   12490              :    nodes.  */
   12491              : 
   12492              : /* Return the hash code X, an OPTIMIZATION_NODE or TARGET_OPTION code.  */
   12493              : 
   12494              : hashval_t
   12495    951312193 : cl_option_hasher::hash (tree x)
   12496              : {
   12497    951312193 :   const_tree const t = x;
   12498              : 
   12499    951312193 :   if (TREE_CODE (t) == OPTIMIZATION_NODE)
   12500    236147792 :     return cl_optimization_hash (TREE_OPTIMIZATION (t));
   12501    715164401 :   else if (TREE_CODE (t) == TARGET_OPTION_NODE)
   12502    715164401 :     return cl_target_option_hash (TREE_TARGET_OPTION (t));
   12503              :   else
   12504            0 :     gcc_unreachable ();
   12505              : }
   12506              : 
   12507              : /* Return nonzero if the value represented by *X (an OPTIMIZATION or
   12508              :    TARGET_OPTION tree node) is the same as that given by *Y, which is the
   12509              :    same.  */
   12510              : 
   12511              : bool
   12512    940202184 : cl_option_hasher::equal (tree x, tree y)
   12513              : {
   12514    940202184 :   const_tree const xt = x;
   12515    940202184 :   const_tree const yt = y;
   12516              : 
   12517    940202184 :   if (TREE_CODE (xt) != TREE_CODE (yt))
   12518              :     return false;
   12519              : 
   12520    519849825 :   if (TREE_CODE (xt) == OPTIMIZATION_NODE)
   12521    101781388 :     return cl_optimization_option_eq (TREE_OPTIMIZATION (xt),
   12522    101781388 :                                       TREE_OPTIMIZATION (yt));
   12523    418068437 :   else if (TREE_CODE (xt) == TARGET_OPTION_NODE)
   12524    418068437 :     return cl_target_option_eq (TREE_TARGET_OPTION (xt),
   12525    418068437 :                                 TREE_TARGET_OPTION (yt));
   12526              :   else
   12527            0 :     gcc_unreachable ();
   12528              : }
   12529              : 
   12530              : /* Build an OPTIMIZATION_NODE based on the options in OPTS and OPTS_SET.  */
   12531              : 
   12532              : tree
   12533    102063379 : build_optimization_node (struct gcc_options *opts,
   12534              :                          struct gcc_options *opts_set)
   12535              : {
   12536    102063379 :   tree t;
   12537              : 
   12538              :   /* Use the cache of optimization nodes.  */
   12539              : 
   12540    102063379 :   cl_optimization_save (TREE_OPTIMIZATION (cl_optimization_node),
   12541              :                         opts, opts_set);
   12542              : 
   12543    102063379 :   tree *slot = cl_option_hash_table->find_slot (cl_optimization_node, INSERT);
   12544    102063379 :   t = *slot;
   12545    102063379 :   if (!t)
   12546              :     {
   12547              :       /* Insert this one into the hash table.  */
   12548       299500 :       t = cl_optimization_node;
   12549       299500 :       *slot = t;
   12550              : 
   12551              :       /* Make a new node for next time round.  */
   12552       299500 :       cl_optimization_node = make_node (OPTIMIZATION_NODE);
   12553              :     }
   12554              : 
   12555    102063379 :   return t;
   12556              : }
   12557              : 
   12558              : /* Build a TARGET_OPTION_NODE based on the options in OPTS and OPTS_SET.  */
   12559              : 
   12560              : tree
   12561     79015859 : build_target_option_node (struct gcc_options *opts,
   12562              :                           struct gcc_options *opts_set)
   12563              : {
   12564     79015859 :   tree t;
   12565              : 
   12566              :   /* Use the cache of optimization nodes.  */
   12567              : 
   12568     79015859 :   cl_target_option_save (TREE_TARGET_OPTION (cl_target_option_node),
   12569              :                          opts, opts_set);
   12570              : 
   12571     79015859 :   tree *slot = cl_option_hash_table->find_slot (cl_target_option_node, INSERT);
   12572     79015859 :   t = *slot;
   12573     79015859 :   if (!t)
   12574              :     {
   12575              :       /* Insert this one into the hash table.  */
   12576       798407 :       t = cl_target_option_node;
   12577       798407 :       *slot = t;
   12578              : 
   12579              :       /* Make a new node for next time round.  */
   12580       798407 :       cl_target_option_node = make_node (TARGET_OPTION_NODE);
   12581              :     }
   12582              : 
   12583     79015859 :   return t;
   12584              : }
   12585              : 
   12586              : /* Clear TREE_TARGET_GLOBALS of all TARGET_OPTION_NODE trees,
   12587              :    so that they aren't saved during PCH writing.  */
   12588              : 
   12589              : void
   12590          428 : prepare_target_option_nodes_for_pch (void)
   12591              : {
   12592          428 :   hash_table<cl_option_hasher>::iterator iter = cl_option_hash_table->begin ();
   12593         1712 :   for (; iter != cl_option_hash_table->end (); ++iter)
   12594          856 :     if (TREE_CODE (*iter) == TARGET_OPTION_NODE)
   12595          428 :       TREE_TARGET_GLOBALS (*iter) = NULL;
   12596          428 : }
   12597              : 
   12598              : /* Determine the "ultimate origin" of a block.  */
   12599              : 
   12600              : tree
   12601    227859375 : block_ultimate_origin (const_tree block)
   12602              : {
   12603    227859375 :   tree origin = BLOCK_ABSTRACT_ORIGIN (block);
   12604              : 
   12605    227859375 :   if (origin == NULL_TREE)
   12606              :     return NULL_TREE;
   12607              :   else
   12608              :     {
   12609    280297300 :       gcc_checking_assert ((DECL_P (origin)
   12610              :                             && DECL_ORIGIN (origin) == origin)
   12611              :                            || BLOCK_ORIGIN (origin) == origin);
   12612              :       return origin;
   12613              :     }
   12614              : }
   12615              : 
   12616              : /* Return true iff conversion from INNER_TYPE to OUTER_TYPE generates
   12617              :    no instruction.  */
   12618              : 
   12619              : bool
   12620   1747415000 : tree_nop_conversion_p (const_tree outer_type, const_tree inner_type)
   12621              : {
   12622   1747415000 :   if (!inner_type || inner_type == error_mark_node)
   12623              :     return false;
   12624              : 
   12625              :   /* Do not strip casts into or out of differing address spaces.  */
   12626   1747377143 :   if (POINTER_TYPE_P (outer_type)
   12627   1747377143 :       && TYPE_ADDR_SPACE (TREE_TYPE (outer_type)) != ADDR_SPACE_GENERIC)
   12628              :     {
   12629          565 :       if (!POINTER_TYPE_P (inner_type)
   12630          565 :           || (TYPE_ADDR_SPACE (TREE_TYPE (outer_type))
   12631          544 :               != TYPE_ADDR_SPACE (TREE_TYPE (inner_type))))
   12632              :         return false;
   12633              :     }
   12634   1747376578 :   else if (POINTER_TYPE_P (inner_type)
   12635   1747376578 :            && TYPE_ADDR_SPACE (TREE_TYPE (inner_type)) != ADDR_SPACE_GENERIC)
   12636              :     {
   12637              :       /* We already know that outer_type is not a pointer with
   12638              :          a non-generic address space.  */
   12639              :       return false;
   12640              :     }
   12641              : 
   12642              :   /* Use precision rather then machine mode when we can, which gives
   12643              :      the correct answer even for submode (bit-field) types.  */
   12644   1747374575 :   if ((INTEGRAL_TYPE_P (outer_type)
   12645    777803024 :        || POINTER_TYPE_P (outer_type)
   12646     73779539 :        || TREE_CODE (outer_type) == OFFSET_TYPE)
   12647   1673606638 :       && (INTEGRAL_TYPE_P (inner_type)
   12648    796904863 :           || POINTER_TYPE_P (inner_type)
   12649      1964846 :           || TREE_CODE (inner_type) == OFFSET_TYPE))
   12650   1671665984 :     return TYPE_PRECISION (outer_type) == TYPE_PRECISION (inner_type);
   12651              : 
   12652     75708591 :   if (TYPE_MODE (outer_type) == BLKmode
   12653     75708591 :       && TYPE_MODE (inner_type) == BLKmode)
   12654              :     {
   12655         7978 :       if (VECTOR_TYPE_P (outer_type)
   12656         5324 :           && VECTOR_TYPE_P (inner_type)
   12657         5324 :           && known_eq (TYPE_VECTOR_SUBPARTS (outer_type),
   12658              :                        TYPE_VECTOR_SUBPARTS (inner_type))
   12659        18626 :           && (TYPE_MODE (TREE_TYPE (outer_type))
   12660         5324 :               == TYPE_MODE (TREE_TYPE (inner_type))))
   12661         5324 :         return true;
   12662         2654 :       return false;
   12663              :     }
   12664              : 
   12665              :   /* Otherwise fall back on comparing machine modes (e.g. for
   12666              :      aggregate types, floats).  */
   12667     75700613 :   return TYPE_MODE (outer_type) == TYPE_MODE (inner_type);
   12668              : }
   12669              : 
   12670              : /* Return true iff a view conversion from vector type INNER_TYPE to vector
   12671              :    type OUTER_TYPE has the same number of elements and does not change the
   12672              :    representation of an element.  */
   12673              : 
   12674              : bool
   12675      6835944 : vector_nop_conversion_p (const_tree outer_type, const_tree inner_type)
   12676              : {
   12677      6835944 :   return (VECTOR_TYPE_P (outer_type)
   12678      3549007 :           && VECTOR_TYPE_P (inner_type)
   12679      3544642 :           && known_eq (TYPE_VECTOR_SUBPARTS (outer_type),
   12680              :                        TYPE_VECTOR_SUBPARTS (inner_type))
   12681      9317206 :           && tree_nop_conversion_p (TREE_TYPE (outer_type),
   12682      2481262 :                                     TREE_TYPE (inner_type)));
   12683              : }
   12684              : 
   12685              : /* Return true iff conversion in EXP generates no instruction.  Mark
   12686              :    it inline so that we fully inline into the stripping functions even
   12687              :    though we have two uses of this function.  */
   12688              : 
   12689              : static inline bool
   12690  20947775408 : tree_nop_conversion (const_tree exp)
   12691              : {
   12692  20947775408 :   tree outer_type, inner_type;
   12693              : 
   12694  20947775408 :   if (location_wrapper_p (exp))
   12695              :     return true;
   12696  20880582216 :   if (!CONVERT_EXPR_P (exp)
   12697  19790777884 :       && TREE_CODE (exp) != NON_LVALUE_EXPR)
   12698              :     return false;
   12699              : 
   12700   1106166203 :   outer_type = TREE_TYPE (exp);
   12701   1106166203 :   inner_type = TREE_TYPE (TREE_OPERAND (exp, 0));
   12702              : 
   12703   1106166203 :   return tree_nop_conversion_p (outer_type, inner_type);
   12704              : }
   12705              : 
   12706              : /* Return true iff conversion in EXP generates no instruction.  Don't
   12707              :    consider conversions changing the signedness.  */
   12708              : 
   12709              : static bool
   12710   2401063203 : tree_sign_nop_conversion (const_tree exp)
   12711              : {
   12712   2401063203 :   tree outer_type, inner_type;
   12713              : 
   12714   2401063203 :   if (!tree_nop_conversion (exp))
   12715              :     return false;
   12716              : 
   12717    238756239 :   outer_type = TREE_TYPE (exp);
   12718    238756239 :   inner_type = TREE_TYPE (TREE_OPERAND (exp, 0));
   12719              : 
   12720    238756239 :   return (TYPE_UNSIGNED (outer_type) == TYPE_UNSIGNED (inner_type)
   12721    238756239 :           && POINTER_TYPE_P (outer_type) == POINTER_TYPE_P (inner_type));
   12722              : }
   12723              : 
   12724              : /* Strip conversions from EXP according to tree_nop_conversion and
   12725              :    return the resulting expression.  */
   12726              : 
   12727              : tree
   12728  17761353877 : tree_strip_nop_conversions (tree exp)
   12729              : {
   12730  18546712205 :   while (tree_nop_conversion (exp))
   12731    785358328 :     exp = TREE_OPERAND (exp, 0);
   12732  17761353877 :   return exp;
   12733              : }
   12734              : 
   12735              : /* Strip conversions from EXP according to tree_sign_nop_conversion
   12736              :    and return the resulting expression.  */
   12737              : 
   12738              : tree
   12739   2189026994 : tree_strip_sign_nop_conversions (tree exp)
   12740              : {
   12741   2401063203 :   while (tree_sign_nop_conversion (exp))
   12742    212036209 :     exp = TREE_OPERAND (exp, 0);
   12743   2189026994 :   return exp;
   12744              : }
   12745              : 
   12746              : /* Avoid any floating point extensions from EXP.  */
   12747              : tree
   12748    100046822 : strip_float_extensions (tree exp)
   12749              : {
   12750    100167494 :   tree sub, expt, subt;
   12751              : 
   12752              :   /*  For floating point constant look up the narrowest type that can hold
   12753              :       it properly and handle it like (type)(narrowest_type)constant.
   12754              :       This way we can optimize for instance a=a*2.0 where "a" is float
   12755              :       but 2.0 is double constant.  */
   12756    100167494 :   if (TREE_CODE (exp) == REAL_CST && !DECIMAL_FLOAT_TYPE_P (TREE_TYPE (exp)))
   12757              :     {
   12758      3261403 :       REAL_VALUE_TYPE orig;
   12759      3261403 :       tree type = NULL;
   12760              : 
   12761      3261403 :       orig = TREE_REAL_CST (exp);
   12762      3261403 :       if (TYPE_PRECISION (TREE_TYPE (exp)) > TYPE_PRECISION (float_type_node)
   12763      3261403 :           && exact_real_truncate (TYPE_MODE (float_type_node), &orig))
   12764       141589 :         type = float_type_node;
   12765      3119814 :       else if (TYPE_PRECISION (TREE_TYPE (exp))
   12766      3119814 :                > TYPE_PRECISION (double_type_node)
   12767      3119814 :                && exact_real_truncate (TYPE_MODE (double_type_node), &orig))
   12768        34571 :         type = double_type_node;
   12769      3261403 :       if (type)
   12770       176160 :         return build_real_truncate (type, orig);
   12771              :     }
   12772              : 
   12773     99991334 :   if (!CONVERT_EXPR_P (exp))
   12774              :     return exp;
   12775              : 
   12776      5523331 :   sub = TREE_OPERAND (exp, 0);
   12777      5523331 :   subt = TREE_TYPE (sub);
   12778      5523331 :   expt = TREE_TYPE (exp);
   12779              : 
   12780      5523331 :   if (!FLOAT_TYPE_P (subt))
   12781              :     return exp;
   12782              : 
   12783       433924 :   if (DECIMAL_FLOAT_TYPE_P (expt) != DECIMAL_FLOAT_TYPE_P (subt))
   12784              :     return exp;
   12785              : 
   12786       145006 :   if (element_precision (subt) > element_precision (expt))
   12787              :     return exp;
   12788              : 
   12789              :   return strip_float_extensions (sub);
   12790              : }
   12791              : 
   12792              : /* Strip out all handled components that produce invariant
   12793              :    offsets.  */
   12794              : 
   12795              : const_tree
   12796   6075276289 : strip_invariant_refs (const_tree op)
   12797              : {
   12798   7087868141 :   while (handled_component_p (op))
   12799              :     {
   12800   1025066579 :       switch (TREE_CODE (op))
   12801              :         {
   12802    200213822 :         case ARRAY_REF:
   12803    200213822 :         case ARRAY_RANGE_REF:
   12804    200213822 :           if (!is_gimple_constant (TREE_OPERAND (op, 1))
   12805    189487622 :               || TREE_OPERAND (op, 2) != NULL_TREE
   12806    187921662 :               || TREE_OPERAND (op, 3) != NULL_TREE)
   12807              :             return NULL;
   12808              :           break;
   12809              : 
   12810    823415682 :         case COMPONENT_REF:
   12811    823415682 :           if (TREE_OPERAND (op, 2) != NULL_TREE)
   12812              :             return NULL;
   12813              :           break;
   12814              : 
   12815   1012591852 :         default:;
   12816              :         }
   12817   1012591852 :       op = TREE_OPERAND (op, 0);
   12818              :     }
   12819              : 
   12820              :   return op;
   12821              : }
   12822              : 
   12823              : /* Strip handled components with zero offset from OP.  */
   12824              : 
   12825              : tree
   12826       559420 : strip_zero_offset_components (tree op)
   12827              : {
   12828       559420 :   while (TREE_CODE (op) == COMPONENT_REF
   12829       426332 :          && integer_zerop (DECL_FIELD_OFFSET (TREE_OPERAND (op, 1)))
   12830      1095123 :          && integer_zerop (DECL_FIELD_BIT_OFFSET (TREE_OPERAND (op, 1))))
   12831       174668 :     op = TREE_OPERAND (op, 0);
   12832       559420 :   return op;
   12833              : }
   12834              : 
   12835              : static GTY(()) tree gcc_eh_personality_decl;
   12836              : 
   12837              : /* Return the GCC personality function decl.  */
   12838              : 
   12839              : tree
   12840          409 : lhd_gcc_personality (void)
   12841              : {
   12842          409 :   if (!gcc_eh_personality_decl)
   12843          164 :     gcc_eh_personality_decl = build_personality_function ("gcc");
   12844          409 :   return gcc_eh_personality_decl;
   12845              : }
   12846              : 
   12847              : /* TARGET is a call target of GIMPLE call statement
   12848              :    (obtained by gimple_call_fn).  Return true if it is
   12849              :    OBJ_TYPE_REF representing an virtual call of C++ method.
   12850              :    (As opposed to OBJ_TYPE_REF representing objc calls
   12851              :    through a cast where middle-end devirtualization machinery
   12852              :    can't apply.)  FOR_DUMP_P is true when being called from
   12853              :    the dump routines.  */
   12854              : 
   12855              : bool
   12856     28741354 : virtual_method_call_p (const_tree target, bool for_dump_p)
   12857              : {
   12858     28741354 :   if (TREE_CODE (target) != OBJ_TYPE_REF)
   12859              :     return false;
   12860      1289992 :   tree t = TREE_TYPE (target);
   12861      1289992 :   gcc_checking_assert (TREE_CODE (t) == POINTER_TYPE);
   12862      1289992 :   t = TREE_TYPE (t);
   12863      1289992 :   if (TREE_CODE (t) == FUNCTION_TYPE)
   12864              :     return false;
   12865      1288708 :   gcc_checking_assert (TREE_CODE (t) == METHOD_TYPE);
   12866              :   /* If we do not have BINFO associated, it means that type was built
   12867              :      without devirtualization enabled.  Do not consider this a virtual
   12868              :      call.  */
   12869      1288708 :   if (!TYPE_BINFO (obj_type_ref_class (target, for_dump_p)))
   12870            0 :     return false;
   12871              :   return true;
   12872              : }
   12873              : 
   12874              : /* Lookup sub-BINFO of BINFO of TYPE at offset POS.  */
   12875              : 
   12876              : static tree
   12877          108 : lookup_binfo_at_offset (tree binfo, tree type, HOST_WIDE_INT pos)
   12878              : {
   12879          108 :   unsigned int i;
   12880          108 :   tree base_binfo, b;
   12881              : 
   12882          124 :   for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
   12883          108 :     if (pos == tree_to_shwi (BINFO_OFFSET (base_binfo))
   12884          108 :         && types_same_for_odr (TREE_TYPE (base_binfo), type))
   12885              :       return base_binfo;
   12886           70 :     else if ((b = lookup_binfo_at_offset (base_binfo, type, pos)) != NULL)
   12887              :       return b;
   12888              :   return NULL;
   12889              : }
   12890              : 
   12891              : /* Try to find a base info of BINFO that would have its field decl at offset
   12892              :    OFFSET within the BINFO type and which is of EXPECTED_TYPE.  If it can be
   12893              :    found, return, otherwise return NULL_TREE.  */
   12894              : 
   12895              : tree
   12896       282770 : get_binfo_at_offset (tree binfo, poly_int64 offset, tree expected_type)
   12897              : {
   12898       282770 :   tree type = BINFO_TYPE (binfo);
   12899              : 
   12900       766702 :   while (true)
   12901              :     {
   12902       524736 :       HOST_WIDE_INT pos, size;
   12903       524736 :       tree fld;
   12904       524736 :       int i;
   12905              : 
   12906       524736 :       if (types_same_for_odr (type, expected_type))
   12907       282770 :           return binfo;
   12908       241966 :       if (maybe_lt (offset, 0))
   12909              :         return NULL_TREE;
   12910              : 
   12911      1203961 :       for (fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld))
   12912              :         {
   12913      1203961 :           if (TREE_CODE (fld) != FIELD_DECL || !DECL_ARTIFICIAL (fld))
   12914       961798 :             continue;
   12915              : 
   12916       242163 :           pos = int_bit_position (fld);
   12917       242163 :           size = tree_to_uhwi (DECL_SIZE (fld));
   12918      1204158 :           if (known_in_range_p (offset, pos, size))
   12919              :             break;
   12920              :         }
   12921       241966 :       if (!fld || TREE_CODE (TREE_TYPE (fld)) != RECORD_TYPE)
   12922              :         return NULL_TREE;
   12923              : 
   12924              :       /* Offset 0 indicates the primary base, whose vtable contents are
   12925              :          represented in the binfo for the derived class.  */
   12926       241966 :       else if (maybe_ne (offset, 0))
   12927              :         {
   12928          197 :           tree found_binfo = NULL, base_binfo;
   12929              :           /* Offsets in BINFO are in bytes relative to the whole structure
   12930              :              while POS is in bits relative to the containing field.  */
   12931          197 :           int binfo_offset = (tree_to_shwi (BINFO_OFFSET (binfo)) + pos
   12932          197 :                              / BITS_PER_UNIT);
   12933              : 
   12934          377 :           for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
   12935          339 :             if (tree_to_shwi (BINFO_OFFSET (base_binfo)) == binfo_offset
   12936          339 :                 && types_same_for_odr (TREE_TYPE (base_binfo), TREE_TYPE (fld)))
   12937              :               {
   12938              :                 found_binfo = base_binfo;
   12939              :                 break;
   12940              :               }
   12941          197 :           if (found_binfo)
   12942              :             binfo = found_binfo;
   12943              :           else
   12944           38 :             binfo = lookup_binfo_at_offset (binfo, TREE_TYPE (fld),
   12945              :                                             binfo_offset);
   12946              :          }
   12947              : 
   12948       241966 :       type = TREE_TYPE (fld);
   12949       241966 :       offset -= pos;
   12950       241966 :     }
   12951              : }
   12952              : 
   12953              : /* PR 84195: Replace control characters in "unescaped" with their
   12954              :    escaped equivalents.  Allow newlines if -fmessage-length has
   12955              :    been set to a non-zero value.  This is done here, rather than
   12956              :    where the attribute is recorded as the message length can
   12957              :    change between these two locations.  */
   12958              : 
   12959              : void
   12960       133902 : escaped_string::escape (const char *unescaped)
   12961              : {
   12962       133902 :   char *escaped;
   12963       133902 :   size_t i, new_i, len;
   12964              : 
   12965       133902 :   if (m_owned)
   12966            8 :     free (m_str);
   12967              : 
   12968       133902 :   m_str = const_cast<char *> (unescaped);
   12969       133902 :   m_owned = false;
   12970              : 
   12971       133902 :   if (unescaped == NULL || *unescaped == 0)
   12972              :     return;
   12973              : 
   12974       133894 :   len = strlen (unescaped);
   12975       133894 :   escaped = NULL;
   12976       133894 :   new_i = 0;
   12977              : 
   12978      3883531 :   for (i = 0; i < len; i++)
   12979              :     {
   12980      3749637 :       char c = unescaped[i];
   12981              : 
   12982      3749637 :       if (!ISCNTRL (c))
   12983              :         {
   12984      3749552 :           if (escaped)
   12985           33 :             escaped[new_i++] = c;
   12986      3749552 :           continue;
   12987              :         }
   12988              : 
   12989           85 :       if (c != '\n' || !pp_is_wrapping_line (global_dc->get_reference_printer ()))
   12990              :         {
   12991           77 :           if (escaped == NULL)
   12992              :             {
   12993              :               /* We only allocate space for a new string if we
   12994              :                  actually encounter a control character that
   12995              :                  needs replacing.  */
   12996           19 :               escaped = (char *) xmalloc (len * 2 + 1);
   12997           19 :               strncpy (escaped, unescaped, i);
   12998           19 :               new_i = i;
   12999              :             }
   13000              : 
   13001           77 :           escaped[new_i++] = '\\';
   13002              : 
   13003           77 :           switch (c)
   13004              :             {
   13005            8 :             case '\a': escaped[new_i++] = 'a'; break;
   13006            8 :             case '\b': escaped[new_i++] = 'b'; break;
   13007            8 :             case '\f': escaped[new_i++] = 'f'; break;
   13008           15 :             case '\n': escaped[new_i++] = 'n'; break;
   13009           15 :             case '\r': escaped[new_i++] = 'r'; break;
   13010           15 :             case '\t': escaped[new_i++] = 't'; break;
   13011            8 :             case '\v': escaped[new_i++] = 'v'; break;
   13012            0 :             default:   escaped[new_i++] = '?'; break;
   13013              :             }
   13014              :         }
   13015            8 :       else if (escaped)
   13016            4 :         escaped[new_i++] = c;
   13017              :     }
   13018              : 
   13019       133894 :   if (escaped)
   13020              :     {
   13021           19 :       escaped[new_i] = 0;
   13022           19 :       m_str = escaped;
   13023           19 :       m_owned = true;
   13024              :     }
   13025              : }
   13026              : 
   13027              : /* Warn about a use of an identifier which was marked deprecated.  Returns
   13028              :    whether a warning was given.  */
   13029              : 
   13030              : bool
   13031      1389398 : warn_deprecated_use (tree node, tree attr)
   13032              : {
   13033      1389398 :   escaped_string msg;
   13034              : 
   13035      1389398 :   if (node == 0 || !warn_deprecated_decl)
   13036              :     return false;
   13037              : 
   13038      1382159 :   if (!attr)
   13039              :     {
   13040      1268888 :       if (DECL_P (node))
   13041      1268718 :         attr = DECL_ATTRIBUTES (node);
   13042          170 :       else if (TYPE_P (node))
   13043              :         {
   13044          170 :           tree decl = TYPE_STUB_DECL (node);
   13045          170 :           if (decl)
   13046          146 :             attr = TYPE_ATTRIBUTES (TREE_TYPE (decl));
   13047           24 :           else if ((decl = TYPE_STUB_DECL (TYPE_MAIN_VARIANT (node)))
   13048              :                    != NULL_TREE)
   13049              :             {
   13050            6 :               node = TREE_TYPE (decl);
   13051            6 :               attr = TYPE_ATTRIBUTES (node);
   13052              :             }
   13053              :         }
   13054              :     }
   13055              : 
   13056      1268888 :   if (attr)
   13057       133434 :     attr = lookup_attribute ("deprecated", attr);
   13058              : 
   13059       133434 :   if (attr)
   13060       133417 :     msg.escape (TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))));
   13061              : 
   13062      1382159 :   bool w = false;
   13063      1382159 :   if (DECL_P (node))
   13064              :     {
   13065      1381979 :       auto_diagnostic_group d;
   13066      1381979 :       if (msg)
   13067       133326 :         w = warning (OPT_Wdeprecated_declarations,
   13068              :                      "%qD is deprecated: %s", node, (const char *) msg);
   13069              :       else
   13070      1248653 :         w = warning (OPT_Wdeprecated_declarations,
   13071              :                      "%qD is deprecated", node);
   13072      1381979 :       if (w)
   13073          806 :         inform (DECL_SOURCE_LOCATION (node), "declared here");
   13074      1381979 :     }
   13075          180 :   else if (TYPE_P (node))
   13076              :     {
   13077          180 :       tree what = NULL_TREE;
   13078          180 :       tree decl = TYPE_STUB_DECL (node);
   13079              : 
   13080          180 :       if (TYPE_NAME (node))
   13081              :         {
   13082          175 :           if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
   13083           10 :             what = TYPE_NAME (node);
   13084          165 :           else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
   13085          165 :                    && DECL_NAME (TYPE_NAME (node)))
   13086          165 :             what = DECL_NAME (TYPE_NAME (node));
   13087              :         }
   13088              : 
   13089          180 :       auto_diagnostic_group d;
   13090          180 :       if (what)
   13091              :         {
   13092          175 :           if (msg)
   13093           89 :             w = warning (OPT_Wdeprecated_declarations,
   13094              :                          "%qE is deprecated: %s", what, (const char *) msg);
   13095              :           else
   13096           86 :             w = warning (OPT_Wdeprecated_declarations,
   13097              :                          "%qE is deprecated", what);
   13098              :         }
   13099              :       else
   13100              :         {
   13101            5 :           if (msg)
   13102            2 :             w = warning (OPT_Wdeprecated_declarations,
   13103              :                          "type is deprecated: %s", (const char *) msg);
   13104              :           else
   13105            3 :             w = warning (OPT_Wdeprecated_declarations,
   13106              :                          "type is deprecated");
   13107              :         }
   13108              : 
   13109          180 :       if (w && decl)
   13110          111 :         inform (DECL_SOURCE_LOCATION (decl), "declared here");
   13111          180 :     }
   13112              : 
   13113              :   return w;
   13114      1389398 : }
   13115              : 
   13116              : /* Error out with an identifier which was marked 'unavailable'. */
   13117              : void
   13118          376 : error_unavailable_use (tree node, tree attr)
   13119              : {
   13120          376 :   escaped_string msg;
   13121              : 
   13122          376 :   if (node == 0)
   13123            0 :     return;
   13124              : 
   13125          376 :   if (!attr)
   13126              :     {
   13127          366 :       if (DECL_P (node))
   13128          306 :         attr = DECL_ATTRIBUTES (node);
   13129           60 :       else if (TYPE_P (node))
   13130              :         {
   13131           60 :           tree decl = TYPE_STUB_DECL (node);
   13132           60 :           if (decl)
   13133           51 :             attr = lookup_attribute ("unavailable",
   13134           51 :                                      TYPE_ATTRIBUTES (TREE_TYPE (decl)));
   13135              :         }
   13136              :     }
   13137              : 
   13138          366 :   if (attr)
   13139          164 :     attr = lookup_attribute ("unavailable", attr);
   13140              : 
   13141          164 :   if (attr)
   13142          164 :     msg.escape (TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))));
   13143              : 
   13144          376 :   if (DECL_P (node))
   13145              :     {
   13146          306 :       auto_diagnostic_group d;
   13147          306 :       if (msg)
   13148          129 :         error ("%qD is unavailable: %s", node, (const char *) msg);
   13149              :       else
   13150          177 :         error ("%qD is unavailable", node);
   13151          306 :       inform (DECL_SOURCE_LOCATION (node), "declared here");
   13152          306 :     }
   13153           70 :   else if (TYPE_P (node))
   13154              :     {
   13155           70 :       tree what = NULL_TREE;
   13156           70 :       tree decl = TYPE_STUB_DECL (node);
   13157              : 
   13158           70 :       if (TYPE_NAME (node))
   13159              :         {
   13160           66 :           if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
   13161            4 :             what = TYPE_NAME (node);
   13162           62 :           else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
   13163           62 :                    && DECL_NAME (TYPE_NAME (node)))
   13164           62 :             what = DECL_NAME (TYPE_NAME (node));
   13165              :         }
   13166              : 
   13167           70 :       auto_diagnostic_group d;
   13168           70 :       if (what)
   13169              :         {
   13170           66 :           if (msg)
   13171           33 :             error ("%qE is unavailable: %s", what, (const char *) msg);
   13172              :           else
   13173           33 :             error ("%qE is unavailable", what);
   13174              :         }
   13175              :       else
   13176              :         {
   13177            4 :           if (msg)
   13178            2 :             error ("type is unavailable: %s", (const char *) msg);
   13179              :           else
   13180            2 :             error ("type is unavailable");
   13181              :         }
   13182              : 
   13183           70 :       if (decl)
   13184           52 :         inform (DECL_SOURCE_LOCATION (decl), "declared here");
   13185           70 :     }
   13186          376 : }
   13187              : 
   13188              : /* Return true if REF has a COMPONENT_REF with a bit-field field declaration
   13189              :    somewhere in it.  */
   13190              : 
   13191              : bool
   13192      5854160 : contains_bitfld_component_ref_p (const_tree ref)
   13193              : {
   13194     11982005 :   while (handled_component_p (ref))
   13195              :     {
   13196      6145156 :       if (TREE_CODE (ref) == COMPONENT_REF
   13197      6145156 :           && DECL_BIT_FIELD (TREE_OPERAND (ref, 1)))
   13198              :         return true;
   13199      6127845 :       ref = TREE_OPERAND (ref, 0);
   13200              :     }
   13201              : 
   13202              :   return false;
   13203              : }
   13204              : 
   13205              : /* Try to determine whether a TRY_CATCH expression can fall through.
   13206              :    This is a subroutine of block_may_fallthru.  */
   13207              : 
   13208              : static bool
   13209            1 : try_catch_may_fallthru (const_tree stmt)
   13210              : {
   13211            1 :   tree_stmt_iterator i;
   13212              : 
   13213              :   /* If the TRY block can fall through, the whole TRY_CATCH can
   13214              :      fall through.  */
   13215            1 :   if (block_may_fallthru (TREE_OPERAND (stmt, 0)))
   13216              :     return true;
   13217              : 
   13218            1 :   switch (TREE_CODE (TREE_OPERAND (stmt, 1)))
   13219              :     {
   13220            0 :     case CATCH_EXPR:
   13221              :       /* See below.  */
   13222            0 :       return block_may_fallthru (CATCH_BODY (TREE_OPERAND (stmt, 1)));
   13223              : 
   13224            0 :     case EH_FILTER_EXPR:
   13225              :       /* See below.  */
   13226            0 :       return block_may_fallthru (EH_FILTER_FAILURE (TREE_OPERAND (stmt, 1)));
   13227              : 
   13228            0 :     case STATEMENT_LIST:
   13229            0 :       break;
   13230              : 
   13231              :     default:
   13232              :       /* See below.  */
   13233              :       return false;
   13234              :     }
   13235              : 
   13236            0 :   i = tsi_start (TREE_OPERAND (stmt, 1));
   13237            0 :   switch (TREE_CODE (tsi_stmt (i)))
   13238              :     {
   13239              :     case CATCH_EXPR:
   13240              :       /* We expect to see a sequence of CATCH_EXPR trees, each with a
   13241              :          catch expression and a body.  The whole TRY_CATCH may fall
   13242              :          through iff any of the catch bodies falls through.  */
   13243            0 :       for (; !tsi_end_p (i); tsi_next (&i))
   13244              :         {
   13245            0 :           if (block_may_fallthru (CATCH_BODY (tsi_stmt (i))))
   13246              :             return true;
   13247              :         }
   13248              :       return false;
   13249              : 
   13250            0 :     case EH_FILTER_EXPR:
   13251              :       /* The exception filter expression only matters if there is an
   13252              :          exception.  If the exception does not match EH_FILTER_TYPES,
   13253              :          we will execute EH_FILTER_FAILURE, and we will fall through
   13254              :          if that falls through.  If the exception does match
   13255              :          EH_FILTER_TYPES, the stack unwinder will continue up the
   13256              :          stack, so we will not fall through.  We don't know whether we
   13257              :          will throw an exception which matches EH_FILTER_TYPES or not,
   13258              :          so we just ignore EH_FILTER_TYPES and assume that we might
   13259              :          throw an exception which doesn't match.  */
   13260            0 :       return block_may_fallthru (EH_FILTER_FAILURE (tsi_stmt (i)));
   13261              : 
   13262              :     default:
   13263              :       /* This case represents statements to be executed when an
   13264              :          exception occurs.  Those statements are implicitly followed
   13265              :          by a RESX statement to resume execution after the exception.
   13266              :          So in this case the TRY_CATCH never falls through.  */
   13267              :       return false;
   13268              :     }
   13269              : }
   13270              : 
   13271              : /* Try to determine if we can fall out of the bottom of BLOCK.  This guess
   13272              :    need not be 100% accurate; simply be conservative and return true if we
   13273              :    don't know.  This is used only to avoid stupidly generating extra code.
   13274              :    If we're wrong, we'll just delete the extra code later.  */
   13275              : 
   13276              : bool
   13277      9318627 : block_may_fallthru (const_tree block)
   13278              : {
   13279              :   /* This CONST_CAST is okay because expr_last returns its argument
   13280              :      unmodified and we assign it to a const_tree.  */
   13281     10770498 :   const_tree stmt = expr_last (const_cast<tree> (block));
   13282              : 
   13283     10770498 :   switch (stmt ? TREE_CODE (stmt) : ERROR_MARK)
   13284              :     {
   13285              :     case GOTO_EXPR:
   13286              :     case RETURN_EXPR:
   13287              :       /* Easy cases.  If the last statement of the block implies
   13288              :          control transfer, then we can't fall through.  */
   13289              :       return false;
   13290              : 
   13291           17 :     case SWITCH_EXPR:
   13292              :       /* If there is a default: label or case labels cover all possible
   13293              :          SWITCH_COND values, then the SWITCH_EXPR will transfer control
   13294              :          to some case label in all cases and all we care is whether the
   13295              :          SWITCH_BODY falls through.  */
   13296           17 :       if (SWITCH_ALL_CASES_P (stmt))
   13297           16 :         return block_may_fallthru (SWITCH_BODY (stmt));
   13298              :       return true;
   13299              : 
   13300        22131 :     case COND_EXPR:
   13301        22131 :       if (block_may_fallthru (COND_EXPR_THEN (stmt)))
   13302              :         return true;
   13303         2829 :       return block_may_fallthru (COND_EXPR_ELSE (stmt));
   13304              : 
   13305       898336 :     case BIND_EXPR:
   13306       898336 :       return block_may_fallthru (BIND_EXPR_BODY (stmt));
   13307              : 
   13308            1 :     case TRY_CATCH_EXPR:
   13309            1 :       return try_catch_may_fallthru (stmt);
   13310              : 
   13311         2123 :     case TRY_FINALLY_EXPR:
   13312              :       /* The finally clause is always executed after the try clause,
   13313              :          so if it does not fall through, then the try-finally will not
   13314              :          fall through.  Otherwise, if the try clause does not fall
   13315              :          through, then when the finally clause falls through it will
   13316              :          resume execution wherever the try clause was going.  So the
   13317              :          whole try-finally will only fall through if both the try
   13318              :          clause and the finally clause fall through.  */
   13319         2123 :       return (block_may_fallthru (TREE_OPERAND (stmt, 0))
   13320         2123 :               && block_may_fallthru (TREE_OPERAND (stmt, 1)));
   13321              : 
   13322            0 :     case EH_ELSE_EXPR:
   13323            0 :       return block_may_fallthru (TREE_OPERAND (stmt, 0));
   13324              : 
   13325        94722 :     case MODIFY_EXPR:
   13326        94722 :       if (TREE_CODE (TREE_OPERAND (stmt, 1)) == CALL_EXPR)
   13327         2795 :         stmt = TREE_OPERAND (stmt, 1);
   13328              :       else
   13329              :         return true;
   13330              :       /* FALLTHRU */
   13331              : 
   13332       324267 :     case CALL_EXPR:
   13333              :       /* Functions that do not return do not fall through.  */
   13334       324267 :       return (call_expr_flags (stmt) & ECF_NORETURN) == 0;
   13335              : 
   13336       550680 :     case CLEANUP_POINT_EXPR:
   13337       550680 :       return block_may_fallthru (TREE_OPERAND (stmt, 0));
   13338              : 
   13339           10 :     case TARGET_EXPR:
   13340           10 :       return block_may_fallthru (TREE_OPERAND (stmt, 1));
   13341              : 
   13342              :     case ERROR_MARK:
   13343              :       return true;
   13344              : 
   13345      6619166 :     default:
   13346      6619166 :       return lang_hooks.block_may_fallthru (stmt);
   13347              :     }
   13348              : }
   13349              : 
   13350              : /* True if we are using EH to handle cleanups.  */
   13351              : static bool using_eh_for_cleanups_flag = false;
   13352              : 
   13353              : /* This routine is called from front ends to indicate eh should be used for
   13354              :    cleanups.  */
   13355              : void
   13356       126345 : using_eh_for_cleanups (void)
   13357              : {
   13358       126345 :   using_eh_for_cleanups_flag = true;
   13359       126345 : }
   13360              : 
   13361              : /* Query whether EH is used for cleanups.  */
   13362              : bool
   13363      1735896 : using_eh_for_cleanups_p (void)
   13364              : {
   13365      1735896 :   return using_eh_for_cleanups_flag;
   13366              : }
   13367              : 
   13368              : /* Wrapper for tree_code_name to ensure that tree code is valid */
   13369              : const char *
   13370  14776060877 : get_tree_code_name (enum tree_code code)
   13371              : {
   13372  14776060877 :   const char *invalid = "<invalid tree code>";
   13373              : 
   13374              :   /* The tree_code enum promotes to signed, but we could be getting
   13375              :      invalid values, so force an unsigned comparison.  */
   13376  14776060877 :   if (unsigned (code) >= MAX_TREE_CODES)
   13377              :     {
   13378            0 :       if ((unsigned)code == 0xa5a5)
   13379              :         return "ggc_freed";
   13380            0 :       return invalid;
   13381              :     }
   13382              : 
   13383  14776060877 :   return tree_code_name[code];
   13384              : }
   13385              : 
   13386              : /* Drops the TREE_OVERFLOW flag from T.  */
   13387              : 
   13388              : tree
   13389        36959 : drop_tree_overflow (tree t)
   13390              : {
   13391        36959 :   gcc_checking_assert (TREE_OVERFLOW (t));
   13392              : 
   13393              :   /* For tree codes with a sharing machinery re-build the result.  */
   13394        36959 :   if (poly_int_tree_p (t))
   13395        36947 :     return wide_int_to_tree (TREE_TYPE (t), wi::to_poly_wide (t));
   13396              : 
   13397              :   /* For VECTOR_CST, remove the overflow bits from the encoded elements
   13398              :      and canonicalize the result.  */
   13399           12 :   if (TREE_CODE (t) == VECTOR_CST)
   13400              :     {
   13401            0 :       tree_vector_builder builder;
   13402            0 :       builder.new_unary_operation (TREE_TYPE (t), t, true);
   13403            0 :       unsigned int count = builder.encoded_nelts ();
   13404            0 :       for (unsigned int i = 0; i < count; ++i)
   13405              :         {
   13406            0 :           tree elt = VECTOR_CST_ELT (t, i);
   13407            0 :           if (TREE_OVERFLOW (elt))
   13408            0 :             elt = drop_tree_overflow (elt);
   13409            0 :           builder.quick_push (elt);
   13410              :         }
   13411            0 :       return builder.build ();
   13412            0 :     }
   13413              : 
   13414              :   /* Otherwise, as all tcc_constants are possibly shared, copy the node
   13415              :      and drop the flag.  */
   13416           12 :   t = copy_node (t);
   13417           12 :   TREE_OVERFLOW (t) = 0;
   13418              : 
   13419              :   /* For constants that contain nested constants, drop the flag
   13420              :      from those as well.  */
   13421           12 :   if (TREE_CODE (t) == COMPLEX_CST)
   13422              :     {
   13423           12 :       if (TREE_OVERFLOW (TREE_REALPART (t)))
   13424           12 :         TREE_REALPART (t) = drop_tree_overflow (TREE_REALPART (t));
   13425           12 :       if (TREE_OVERFLOW (TREE_IMAGPART (t)))
   13426            0 :         TREE_IMAGPART (t) = drop_tree_overflow (TREE_IMAGPART (t));
   13427              :     }
   13428              : 
   13429              :   return t;
   13430              : }
   13431              : 
   13432              : /* Given a memory reference expression T, return its base address.
   13433              :    The base address of a memory reference expression is the main
   13434              :    object being referenced.  For instance, the base address for
   13435              :    'array[i].fld[j]' is 'array'.  You can think of this as stripping
   13436              :    away the offset part from a memory address.
   13437              : 
   13438              :    This function calls handled_component_p to strip away all the inner
   13439              :    parts of the memory reference until it reaches the base object.  */
   13440              : 
   13441              : tree
   13442   3296632000 : get_base_address (tree t)
   13443              : {
   13444   3296632000 :   if (TREE_CODE (t) == WITH_SIZE_EXPR)
   13445          899 :     t = TREE_OPERAND (t, 0);
   13446   4103668295 :   while (handled_component_p (t))
   13447    807036295 :     t = TREE_OPERAND (t, 0);
   13448              : 
   13449   3296632000 :   if ((TREE_CODE (t) == MEM_REF
   13450   3296632000 :        || TREE_CODE (t) == TARGET_MEM_REF)
   13451   3296632000 :       && TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR)
   13452    150025563 :     t = TREE_OPERAND (TREE_OPERAND (t, 0), 0);
   13453              : 
   13454   3296632000 :   return t;
   13455              : }
   13456              : 
   13457              : /* Return a tree of sizetype representing the size, in bytes, of the element
   13458              :    of EXP, an ARRAY_REF or an ARRAY_RANGE_REF.  */
   13459              : 
   13460              : tree
   13461    804957035 : array_ref_element_size (tree exp)
   13462              : {
   13463    804957035 :   tree aligned_size = TREE_OPERAND (exp, 3);
   13464    804957035 :   tree elmt_type = TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0)));
   13465    804957035 :   location_t loc = EXPR_LOCATION (exp);
   13466              : 
   13467              :   /* If a size was specified in the ARRAY_REF, it's the size measured
   13468              :      in alignment units of the element type.  So multiply by that value.  */
   13469    804957035 :   if (aligned_size)
   13470              :     {
   13471              :       /* ??? tree_ssa_useless_type_conversion will eliminate casts to
   13472              :          sizetype from another type of the same width and signedness.  */
   13473       341145 :       if (TREE_TYPE (aligned_size) != sizetype)
   13474         5268 :         aligned_size = fold_convert_loc (loc, sizetype, aligned_size);
   13475       341145 :       return size_binop_loc (loc, MULT_EXPR, aligned_size,
   13476       341145 :                              size_int (TYPE_ALIGN_UNIT (elmt_type)));
   13477              :     }
   13478              : 
   13479              :   /* Otherwise, take the size from that of the element type.  Substitute
   13480              :      any PLACEHOLDER_EXPR that we have.  */
   13481              :   else
   13482    804615890 :     return SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_SIZE_UNIT (elmt_type), exp);
   13483              : }
   13484              : 
   13485              : /* Return a tree representing the lower bound of the array mentioned in
   13486              :    EXP, an ARRAY_REF or an ARRAY_RANGE_REF.  */
   13487              : 
   13488              : tree
   13489   1108871034 : array_ref_low_bound (tree exp)
   13490              : {
   13491   1108871034 :   tree domain_type = TYPE_DOMAIN (TREE_TYPE (TREE_OPERAND (exp, 0)));
   13492              : 
   13493              :   /* If a lower bound is specified in EXP, use it.  */
   13494   1108871034 :   if (TREE_OPERAND (exp, 2))
   13495      1962921 :     return TREE_OPERAND (exp, 2);
   13496              : 
   13497              :   /* Otherwise, if there is a domain type and it has a lower bound, use it,
   13498              :      substituting for a PLACEHOLDER_EXPR as needed.  */
   13499   1106908113 :   if (domain_type && TYPE_MIN_VALUE (domain_type))
   13500   1105985019 :     return SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_MIN_VALUE (domain_type), exp);
   13501              : 
   13502              :   /* Otherwise, return a zero of the appropriate type.  */
   13503       923094 :   tree idxtype = TREE_TYPE (TREE_OPERAND (exp, 1));
   13504       923094 :   return (idxtype == error_mark_node
   13505       923094 :           ? integer_zero_node : build_int_cst (idxtype, 0));
   13506              : }
   13507              : 
   13508              : /* Return a tree representing the upper bound of the array mentioned in
   13509              :    EXP, an ARRAY_REF or an ARRAY_RANGE_REF.  */
   13510              : 
   13511              : tree
   13512    253052259 : array_ref_up_bound (tree exp)
   13513              : {
   13514    253052259 :   tree domain_type = TYPE_DOMAIN (TREE_TYPE (TREE_OPERAND (exp, 0)));
   13515              : 
   13516              :   /* If there is a domain type and it has an upper bound, use it, substituting
   13517              :      for a PLACEHOLDER_EXPR as needed.  */
   13518    253052259 :   if (domain_type && TYPE_MAX_VALUE (domain_type))
   13519    252235747 :     return SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_MAX_VALUE (domain_type), exp);
   13520              : 
   13521              :   /* Otherwise fail.  */
   13522              :   return NULL_TREE;
   13523              : }
   13524              : 
   13525              : /* Returns true if REF is an array reference, a component reference,
   13526              :    or a memory reference to an array whose actual size might be larger
   13527              :    than its upper bound implies, there are multiple cases:
   13528              :    A. a ref to a flexible array member at the end of a structure;
   13529              :    B. a ref to an array with a different type against the original decl;
   13530              :       for example:
   13531              : 
   13532              :    short a[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
   13533              :    (*((char(*)[16])&a[0]))[i+8]
   13534              : 
   13535              :    C. a ref to an array that was passed as a parameter;
   13536              :       for example:
   13537              : 
   13538              :    int test (uint8_t *p, uint32_t t[1][1], int n) {
   13539              :    for (int i = 0; i < 4; i++, p++)
   13540              :      t[i][0] = ...;
   13541              : 
   13542              :    If non-null, set IS_TRAILING_ARRAY to true if the ref is the above case A.
   13543              : */
   13544              : 
   13545              : bool
   13546     77083144 : array_ref_flexible_size_p (tree ref, bool *is_trailing_array /* = NULL */)
   13547              : {
   13548              :   /* The TYPE for this array reference.  */
   13549     77083144 :   tree atype = NULL_TREE;
   13550              :   /* The FIELD_DECL for the array field in the containing structure.  */
   13551     77083144 :   tree afield_decl = NULL_TREE;
   13552              :   /* Whether this array is the trailing array of a structure.  */
   13553     77083144 :   bool is_trailing_array_tmp = false;
   13554     77083144 :   if (!is_trailing_array)
   13555     77001243 :     is_trailing_array = &is_trailing_array_tmp;
   13556              : 
   13557     77083144 :   if (TREE_CODE (ref) == ARRAY_REF
   13558     77083144 :       || TREE_CODE (ref) == ARRAY_RANGE_REF)
   13559              :     {
   13560     76840301 :       atype = TREE_TYPE (TREE_OPERAND (ref, 0));
   13561     76840301 :       ref = TREE_OPERAND (ref, 0);
   13562              :     }
   13563       242843 :   else if (TREE_CODE (ref) == COMPONENT_REF
   13564       242843 :            && TREE_CODE (TREE_TYPE (TREE_OPERAND (ref, 1))) == ARRAY_TYPE)
   13565              :     {
   13566       171044 :       atype = TREE_TYPE (TREE_OPERAND (ref, 1));
   13567       171044 :       afield_decl = TREE_OPERAND (ref, 1);
   13568              :     }
   13569        71799 :   else if (TREE_CODE (ref) == MEM_REF)
   13570              :     {
   13571         7641 :       tree arg = TREE_OPERAND (ref, 0);
   13572         7641 :       if (TREE_CODE (arg) == ADDR_EXPR)
   13573         7641 :         arg = TREE_OPERAND (arg, 0);
   13574         7641 :       tree argtype = TREE_TYPE (arg);
   13575         7641 :       if (TREE_CODE (argtype) == RECORD_TYPE)
   13576              :         {
   13577          157 :           if (tree fld = last_field (argtype))
   13578              :             {
   13579          157 :               atype = TREE_TYPE (fld);
   13580          157 :               afield_decl = fld;
   13581          157 :               if (TREE_CODE (atype) != ARRAY_TYPE)
   13582              :                 return false;
   13583          157 :               if (VAR_P (arg) && DECL_SIZE (fld))
   13584              :                 return false;
   13585              :             }
   13586              :           else
   13587              :             return false;
   13588              :         }
   13589              :       else
   13590              :         return false;
   13591              :     }
   13592              :   else
   13593              :     return false;
   13594              : 
   13595     77011458 :   if (TREE_CODE (ref) == STRING_CST)
   13596              :     return false;
   13597              : 
   13598              :   tree ref_to_array = ref;
   13599     94455201 :   while (handled_component_p (ref))
   13600              :     {
   13601              :       /* If the reference chain contains a component reference to a
   13602              :          non-union type and there follows another field the reference
   13603              :          is not at the end of a structure.  */
   13604     20657087 :       if (TREE_CODE (ref) == COMPONENT_REF)
   13605              :         {
   13606     19507335 :           if (TREE_CODE (TREE_TYPE (TREE_OPERAND (ref, 0))) == RECORD_TYPE)
   13607              :             {
   13608     18241013 :               tree nextf = DECL_CHAIN (TREE_OPERAND (ref, 1));
   13609     41978716 :               while (nextf && TREE_CODE (nextf) != FIELD_DECL)
   13610     23737703 :                 nextf = DECL_CHAIN (nextf);
   13611              :               if (nextf)
   13612              :                 return false;
   13613              :             }
   13614              :         }
   13615              :       /* If we have a multi-dimensional array we do not consider
   13616              :          a non-innermost dimension as flex array if the whole
   13617              :          multi-dimensional array is at struct end.
   13618              :          Same for an array of aggregates with a trailing array
   13619              :          member.  */
   13620      1149752 :       else if (TREE_CODE (ref) == ARRAY_REF)
   13621              :         return false;
   13622       204680 :       else if (TREE_CODE (ref) == ARRAY_RANGE_REF)
   13623              :         ;
   13624              :       /* If we view an underlying object as sth else then what we
   13625              :          gathered up to now is what we have to rely on.  */
   13626       204664 :       else if (TREE_CODE (ref) == VIEW_CONVERT_EXPR)
   13627              :         break;
   13628              :       else
   13629            0 :         gcc_unreachable ();
   13630              : 
   13631     17444977 :       ref = TREE_OPERAND (ref, 0);
   13632              :     }
   13633              : 
   13634     74002778 :   gcc_assert (!afield_decl
   13635              :               || (afield_decl && TREE_CODE (afield_decl) == FIELD_DECL));
   13636              : 
   13637              :   /* The array now is at struct end.  Treat flexible array member as
   13638              :      always subject to extend, even into just padding constrained by
   13639              :      an underlying decl.  */
   13640     74002778 :   if (! TYPE_SIZE (atype)
   13641     71410779 :       || ! TYPE_DOMAIN (atype)
   13642    145413557 :       || ! TYPE_MAX_VALUE (TYPE_DOMAIN (atype)))
   13643              :     {
   13644      2597388 :       *is_trailing_array = afield_decl && TREE_CODE (afield_decl) == FIELD_DECL;
   13645      2597388 :       return afield_decl ? !DECL_NOT_FLEXARRAY (afield_decl) : true;
   13646              :     }
   13647              : 
   13648              :   /* If the reference is based on a declared entity, the size of the array
   13649              :      is constrained by its given domain.  (Do not trust commons PR/69368).  */
   13650     71405390 :   ref = get_base_address (ref);
   13651     71405390 :   if (ref
   13652     71405390 :       && DECL_P (ref)
   13653     60976753 :       && !(flag_unconstrained_commons
   13654           14 :            && VAR_P (ref) && DECL_COMMON (ref))
   13655     60976739 :       && DECL_SIZE_UNIT (ref)
   13656    132381752 :       && TREE_CODE (DECL_SIZE_UNIT (ref)) == INTEGER_CST)
   13657              :     {
   13658              :       /* If the object itself is the array it is not at struct end.  */
   13659     60976334 :       if (DECL_P (ref_to_array))
   13660              :         return false;
   13661              : 
   13662              :       /* Check whether the array domain covers all of the available
   13663              :          padding.  */
   13664     15824454 :       poly_int64 offset;
   13665     15824454 :       if (TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (atype))) != INTEGER_CST
   13666     15823094 :           || TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (atype))) != INTEGER_CST
   13667     31625018 :           || TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (atype))) != INTEGER_CST)
   13668              :         {
   13669        23890 :           *is_trailing_array
   13670        23890 :             = afield_decl && TREE_CODE (afield_decl) == FIELD_DECL;
   13671        23890 :           return afield_decl ? !DECL_NOT_FLEXARRAY (afield_decl) : true;
   13672              :         }
   13673     15800564 :       if (! get_addr_base_and_unit_offset (ref_to_array, &offset))
   13674              :         {
   13675         2847 :           *is_trailing_array
   13676         2847 :             = afield_decl && TREE_CODE (afield_decl) == FIELD_DECL;
   13677         2847 :           return afield_decl ? !DECL_NOT_FLEXARRAY (afield_decl) : true;
   13678              :         }
   13679              : 
   13680              :       /* If at least one extra element fits it is a flexarray.  */
   13681     15797717 :       if (known_le ((wi::to_offset (TYPE_MAX_VALUE (TYPE_DOMAIN (atype)))
   13682              :                      - wi::to_offset (TYPE_MIN_VALUE (TYPE_DOMAIN (atype)))
   13683              :                      + 2)
   13684              :                     * wi::to_offset (TYPE_SIZE_UNIT (TREE_TYPE (atype))),
   13685              :                     wi::to_offset (DECL_SIZE_UNIT (ref)) - offset))
   13686              :         {
   13687       388894 :           *is_trailing_array
   13688       388894 :             = afield_decl && TREE_CODE (afield_decl) == FIELD_DECL;
   13689       388894 :           return afield_decl ? !DECL_NOT_FLEXARRAY (afield_decl) : true;
   13690              :         }
   13691              : 
   13692              :       return false;
   13693              :     }
   13694              : 
   13695     10429056 :   *is_trailing_array = afield_decl && TREE_CODE (afield_decl) == FIELD_DECL;
   13696     10429056 :   return afield_decl ? !DECL_NOT_FLEXARRAY (afield_decl) : true;
   13697              : }
   13698              : 
   13699              : 
   13700              : /* Return a tree representing the offset, in bytes, of the field referenced
   13701              :    by EXP.  This does not include any offset in DECL_FIELD_BIT_OFFSET.  */
   13702              : 
   13703              : tree
   13704   2792580716 : component_ref_field_offset (tree exp)
   13705              : {
   13706   2792580716 :   tree aligned_offset = TREE_OPERAND (exp, 2);
   13707   2792580716 :   tree field = TREE_OPERAND (exp, 1);
   13708   2792580716 :   location_t loc = EXPR_LOCATION (exp);
   13709              : 
   13710              :   /* If an offset was specified in the COMPONENT_REF, it's the offset measured
   13711              :      in units of DECL_OFFSET_ALIGN / BITS_PER_UNIT.  So multiply by that
   13712              :      value.  */
   13713   2792580716 :   if (aligned_offset)
   13714              :     {
   13715              :       /* ??? tree_ssa_useless_type_conversion will eliminate casts to
   13716              :          sizetype from another type of the same width and signedness.  */
   13717        11907 :       if (TREE_TYPE (aligned_offset) != sizetype)
   13718          133 :         aligned_offset = fold_convert_loc (loc, sizetype, aligned_offset);
   13719        11907 :       return size_binop_loc (loc, MULT_EXPR, aligned_offset,
   13720        11907 :                              size_int (DECL_OFFSET_ALIGN (field)
   13721              :                                        / BITS_PER_UNIT));
   13722              :     }
   13723              : 
   13724              :   /* Otherwise, take the offset from that of the field.  Substitute
   13725              :      any PLACEHOLDER_EXPR that we have.  */
   13726              :   else
   13727   2792568809 :     return SUBSTITUTE_PLACEHOLDER_IN_EXPR (DECL_FIELD_OFFSET (field), exp);
   13728              : }
   13729              : 
   13730              : /* Given the initializer INIT, return the initializer for the field
   13731              :    DECL if it exists, otherwise null.  Used to obtain the initializer
   13732              :    for a flexible array member and determine its size.  */
   13733              : 
   13734              : static tree
   13735         1267 : get_initializer_for (tree init, tree decl)
   13736              : {
   13737         1267 :   STRIP_NOPS (init);
   13738              : 
   13739         1267 :   tree fld, fld_init;
   13740         1267 :   unsigned HOST_WIDE_INT i;
   13741         3571 :   FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (init), i, fld, fld_init)
   13742              :     {
   13743         1926 :       if (decl == fld)
   13744              :         return fld_init;
   13745              : 
   13746         1037 :       if (TREE_CODE (fld) == CONSTRUCTOR)
   13747              :         {
   13748            0 :           fld_init = get_initializer_for (fld_init, decl);
   13749            0 :           if (fld_init)
   13750              :             return fld_init;
   13751              :         }
   13752              :     }
   13753              : 
   13754              :   return NULL_TREE;
   13755              : }
   13756              : 
   13757              : /* Determines the special array member type for the array reference REF.  */
   13758              : special_array_member
   13759       255491 : component_ref_sam_type (tree ref)
   13760              : {
   13761       255491 :   special_array_member sam_type = special_array_member::none;
   13762              : 
   13763       255491 :   tree member = TREE_OPERAND (ref, 1);
   13764       255491 :   tree memsize = DECL_SIZE_UNIT (member);
   13765       255491 :   if (memsize)
   13766              :     {
   13767       123421 :       tree memtype = TREE_TYPE (member);
   13768       123421 :       if (TREE_CODE (memtype) != ARRAY_TYPE)
   13769       123299 :         return sam_type;
   13770              : 
   13771        81901 :       bool trailing = false;
   13772        81901 :       (void) array_ref_flexible_size_p (ref, &trailing);
   13773        81901 :       bool zero_elts = integer_zerop (memsize);
   13774        81901 :       if (zero_elts && integer_zerop (TYPE_SIZE_UNIT (TREE_TYPE (memtype))))
   13775              :         {
   13776              :           /* If array element has zero size, verify if it is a flexible
   13777              :              array member or zero length array.  Clear zero_elts if
   13778              :              it has one or more members or is a VLA member.  */
   13779            6 :           if (tree dom = TYPE_DOMAIN (memtype))
   13780            6 :             if (tree min = TYPE_MIN_VALUE (dom))
   13781            6 :               if (tree max = TYPE_MAX_VALUE (dom))
   13782            4 :                 if (TREE_CODE (min) != INTEGER_CST
   13783            4 :                     || TREE_CODE (max) != INTEGER_CST
   13784           12 :                     || !((integer_zerop (min) && integer_all_onesp (max))
   13785            4 :                          || tree_int_cst_lt (max, min)))
   13786              :                   zero_elts = false;
   13787              :         }
   13788        81901 :       if (!trailing && !zero_elts)
   13789              :         /* MEMBER is an interior array with more than one element.  */
   13790              :         return special_array_member::int_n;
   13791              : 
   13792        23329 :       if (zero_elts)
   13793              :         {
   13794         1074 :           if (trailing)
   13795              :             return special_array_member::trail_0;
   13796              :           else
   13797          463 :             return special_array_member::int_0;
   13798              :         }
   13799              : 
   13800        22718 :       if (!zero_elts)
   13801        22718 :         if (tree dom = TYPE_DOMAIN (memtype))
   13802        22718 :           if (tree min = TYPE_MIN_VALUE (dom))
   13803        22718 :             if (tree max = TYPE_MAX_VALUE (dom))
   13804        22718 :               if (TREE_CODE (min) == INTEGER_CST
   13805        22718 :                   && TREE_CODE (max) == INTEGER_CST)
   13806              :                 {
   13807        22596 :                   offset_int minidx = wi::to_offset (min);
   13808        22596 :                   offset_int maxidx = wi::to_offset (max);
   13809        22596 :                   offset_int neltsm1 = maxidx - minidx;
   13810        22596 :                   if (neltsm1 > 0)
   13811              :                     /* MEMBER is a trailing array with more than
   13812              :                        one elements.  */
   13813        22596 :                     return special_array_member::trail_n;
   13814              : 
   13815         2182 :                   if (neltsm1 == 0)
   13816              :                     return special_array_member::trail_1;
   13817              :                 }
   13818              :     }
   13819              : 
   13820              :   return sam_type;
   13821              : }
   13822              : 
   13823              : /* Determines the size of the member referenced by the COMPONENT_REF
   13824              :    REF, using its initializer expression if necessary in order to
   13825              :    determine the size of an initialized flexible array member.
   13826              :    If non-null, set *SAM to the type of special array member.
   13827              :    Returns the size as sizetype (which might be zero for an object
   13828              :    with an uninitialized flexible array member) or null if the size
   13829              :    cannot be determined.  */
   13830              : 
   13831              : tree
   13832       156132 : component_ref_size (tree ref, special_array_member *sam /* = NULL */)
   13833              : {
   13834       156132 :   gcc_assert (TREE_CODE (ref) == COMPONENT_REF);
   13835              : 
   13836       156132 :   special_array_member sambuf;
   13837       156132 :   if (!sam)
   13838        99343 :     sam = &sambuf;
   13839       156132 :   *sam = component_ref_sam_type (ref);
   13840              : 
   13841              :   /* The object/argument referenced by the COMPONENT_REF and its type.  */
   13842       156132 :   tree arg = TREE_OPERAND (ref, 0);
   13843       156132 :   tree argtype = TREE_TYPE (arg);
   13844              :   /* The referenced member.  */
   13845       156132 :   tree member = TREE_OPERAND (ref, 1);
   13846              : 
   13847       156132 :   tree memsize = DECL_SIZE_UNIT (member);
   13848       156132 :   if (memsize)
   13849              :     {
   13850        88565 :       tree memtype = TREE_TYPE (member);
   13851        88565 :       if (TREE_CODE (memtype) != ARRAY_TYPE)
   13852              :         /* DECL_SIZE may be less than TYPE_SIZE in C++ when referring
   13853              :            to the type of a class with a virtual base which doesn't
   13854              :            reflect the size of the virtual's members (see pr97595).
   13855              :            If that's the case fail for now and implement something
   13856              :            more robust in the future.  */
   13857        41520 :         return (tree_int_cst_equal (memsize, TYPE_SIZE_UNIT (memtype))
   13858        41520 :                 ? memsize : NULL_TREE);
   13859              : 
   13860              :       /* 2-or-more elements arrays are treated as normal arrays by default.  */
   13861        47045 :       if (*sam == special_array_member::int_n
   13862        47045 :           || *sam == special_array_member::trail_n)
   13863              :         return memsize;
   13864              : 
   13865         1849 :       tree afield_decl = TREE_OPERAND (ref, 1);
   13866         1849 :       gcc_assert (TREE_CODE (afield_decl) == FIELD_DECL);
   13867              :       /* If the trailing array is a not a flexible array member, treat it as
   13868              :          a normal array.  */
   13869         1849 :       if (DECL_NOT_FLEXARRAY (afield_decl)
   13870         1849 :           && *sam != special_array_member::int_0)
   13871              :         return memsize;
   13872              : 
   13873         1840 :       if (*sam == special_array_member::int_0)
   13874          270 :         memsize = NULL_TREE;
   13875              : 
   13876              :       /* For a reference to a flexible array member of a union
   13877              :          use the size of the union instead of the size of the member.  */
   13878         1840 :       if (TREE_CODE (argtype) == UNION_TYPE)
   13879          277 :         memsize = TYPE_SIZE_UNIT (argtype);
   13880              :     }
   13881              : 
   13882              :   /* MEMBER is either a bona fide flexible array member, or a zero-elements
   13883              :      array member, or an array of length one treated as such.  */
   13884              : 
   13885              :   /* If the reference is to a declared object and the member a true
   13886              :      flexible array, try to determine its size from its initializer.  */
   13887        69407 :   poly_int64 baseoff = 0;
   13888        69407 :   tree base = get_addr_base_and_unit_offset (ref, &baseoff);
   13889        69407 :   if (!base || !VAR_P (base))
   13890              :     {
   13891        66075 :       if (*sam != special_array_member::int_0)
   13892              :         return NULL_TREE;
   13893              : 
   13894           52 :       if (TREE_CODE (arg) != COMPONENT_REF)
   13895              :         return NULL_TREE;
   13896              : 
   13897              :       base = arg;
   13898            6 :       while (TREE_CODE (base) == COMPONENT_REF)
   13899            3 :         base = TREE_OPERAND (base, 0);
   13900            3 :       baseoff = tree_to_poly_int64 (byte_position (TREE_OPERAND (ref, 1)));
   13901              :     }
   13902              : 
   13903              :   /* BASE is the declared object of which MEMBER is either a member
   13904              :      or that is cast to ARGTYPE (e.g., a char buffer used to store
   13905              :      an ARGTYPE object).  */
   13906         3335 :   tree basetype = TREE_TYPE (base);
   13907              : 
   13908              :   /* Determine the base type of the referenced object.  If it's
   13909              :      the same as ARGTYPE and MEMBER has a known size, return it.  */
   13910         3335 :   tree bt = basetype;
   13911         3335 :   if (*sam != special_array_member::int_0)
   13912         3336 :     while (TREE_CODE (bt) == ARRAY_TYPE)
   13913          222 :       bt = TREE_TYPE (bt);
   13914         3335 :   bool typematch = useless_type_conversion_p (argtype, bt);
   13915         3335 :   if (memsize && typematch)
   13916              :     return memsize;
   13917              : 
   13918         3245 :   memsize = NULL_TREE;
   13919              : 
   13920         3245 :   if (typematch)
   13921              :     /* MEMBER is a true flexible array member.  Compute its size from
   13922              :        the initializer of the BASE object if it has one.  */
   13923         2681 :     if (tree init = DECL_P (base) ? DECL_INITIAL (base) : NULL_TREE)
   13924         1300 :       if (init != error_mark_node)
   13925              :         {
   13926         1267 :           init = get_initializer_for (init, member);
   13927         1267 :           if (init)
   13928              :             {
   13929          889 :               memsize = TYPE_SIZE_UNIT (TREE_TYPE (init));
   13930          889 :               if (tree refsize = TYPE_SIZE_UNIT (argtype))
   13931              :                 {
   13932              :                   /* Use the larger of the initializer size and the tail
   13933              :                      padding in the enclosing struct.  */
   13934          889 :                   poly_int64 rsz = tree_to_poly_int64 (refsize);
   13935          889 :                   rsz -= baseoff;
   13936          889 :                   if (known_lt (tree_to_poly_int64 (memsize), rsz))
   13937           56 :                     memsize = wide_int_to_tree (TREE_TYPE (memsize), rsz);
   13938              :                 }
   13939              : 
   13940          889 :               baseoff = 0;
   13941              :             }
   13942              :         }
   13943              : 
   13944          889 :   if (!memsize)
   13945              :     {
   13946         2356 :       if (typematch)
   13947              :         {
   13948         1792 :           if (DECL_P (base)
   13949         1792 :               && DECL_EXTERNAL (base)
   13950          454 :               && bt == basetype
   13951         2240 :               && *sam != special_array_member::int_0)
   13952              :             /* The size of a flexible array member of an extern struct
   13953              :                with no initializer cannot be determined (it's defined
   13954              :                in another translation unit and can have an initializer
   13955              :                with an arbitrary number of elements).  */
   13956              :             return NULL_TREE;
   13957              : 
   13958              :           /* Use the size of the base struct or, for interior zero-length
   13959              :              arrays, the size of the enclosing type.  */
   13960         1367 :           memsize = TYPE_SIZE_UNIT (bt);
   13961              :         }
   13962          564 :       else if (DECL_P (base))
   13963              :         /* Use the size of the BASE object (possibly an array of some
   13964              :            other type such as char used to store the struct).  */
   13965          561 :         memsize = DECL_SIZE_UNIT (base);
   13966              :       else
   13967              :         return NULL_TREE;
   13968              :     }
   13969              : 
   13970              :   /* If the flexible array member has a known size use the greater
   13971              :      of it and the tail padding in the enclosing struct.
   13972              :      Otherwise, when the size of the flexible array member is unknown
   13973              :      and the referenced object is not a struct, use the size of its
   13974              :      type when known.  This detects sizes of array buffers when cast
   13975              :      to struct types with flexible array members.  */
   13976         1928 :   if (memsize)
   13977              :     {
   13978         2792 :       if (!tree_fits_poly_int64_p (memsize))
   13979              :         return NULL_TREE;
   13980         2792 :       poly_int64 memsz64 = memsize ? tree_to_poly_int64 (memsize) : 0;
   13981         2792 :       if (known_lt (baseoff, memsz64))
   13982              :         {
   13983         1341 :           memsz64 -= baseoff;
   13984         1341 :           return wide_int_to_tree (TREE_TYPE (memsize), memsz64);
   13985              :         }
   13986         1451 :       return size_zero_node;
   13987              :     }
   13988              : 
   13989              :   /* Return "don't know" for an external non-array object since its
   13990              :      flexible array member can be initialized to have any number of
   13991              :      elements.  Otherwise, return zero because the flexible array
   13992              :      member has no elements.  */
   13993           25 :   return (DECL_P (base)
   13994           25 :           && DECL_EXTERNAL (base)
   13995           25 :           && (!typematch
   13996            0 :               || TREE_CODE (basetype) != ARRAY_TYPE)
   13997           25 :           ? NULL_TREE : size_zero_node);
   13998              : }
   13999              : 
   14000              : /* Return true if the given node CALL is a call to a .ACCESS_WITH_SIZE
   14001              :    function.  */
   14002              : bool
   14003    169332974 : is_access_with_size_p (const_tree call)
   14004              : {
   14005    169332974 :   if (TREE_CODE (call) != CALL_EXPR)
   14006              :     return false;
   14007     43916702 :   if (CALL_EXPR_IFN (call) == IFN_ACCESS_WITH_SIZE)
   14008         1073 :     return true;
   14009              :   return false;
   14010              : }
   14011              : 
   14012              : /* Get the corresponding reference from the call to a .ACCESS_WITH_SIZE.
   14013              :  * i.e the first argument of this call.  Return NULL_TREE otherwise.  */
   14014              : tree
   14015            3 : get_ref_from_access_with_size (tree call)
   14016              : {
   14017            3 :   if (is_access_with_size_p (call))
   14018            3 :     return  CALL_EXPR_ARG (call, 0);
   14019              :   return NULL_TREE;
   14020              : }
   14021              : 
   14022              : /* Return the machine mode of T.  For vectors, returns the mode of the
   14023              :    inner type.  The main use case is to feed the result to HONOR_NANS,
   14024              :    avoiding the BLKmode that a direct TYPE_MODE (T) might return.  */
   14025              : 
   14026              : machine_mode
   14027   5984589803 : element_mode (const_tree t)
   14028              : {
   14029   5984589803 :   if (!TYPE_P (t))
   14030    207587939 :     t = TREE_TYPE (t);
   14031   5984589803 :   if (VECTOR_TYPE_P (t) || TREE_CODE (t) == COMPLEX_TYPE)
   14032   1572425727 :     t = TREE_TYPE (t);
   14033   5984589803 :   return TYPE_MODE (t);
   14034              : }
   14035              : 
   14036              : /* Vector types need to re-check the target flags each time we report
   14037              :    the machine mode.  We need to do this because attribute target can
   14038              :    change the result of vector_mode_supported_p and have_regs_of_mode
   14039              :    on a per-function basis.  Thus the TYPE_MODE of a VECTOR_TYPE can
   14040              :    change on a per-function basis.  */
   14041              : /* ??? Possibly a better solution is to run through all the types
   14042              :    referenced by a function and re-compute the TYPE_MODE once, rather
   14043              :    than make the TYPE_MODE macro call a function.  */
   14044              : 
   14045              : machine_mode
   14046   1376397655 : vector_type_mode (const_tree t)
   14047              : {
   14048   1376397655 :   machine_mode mode;
   14049              : 
   14050   1376397655 :   gcc_assert (TREE_CODE (t) == VECTOR_TYPE);
   14051              : 
   14052   1376397655 :   mode = t->type_common.mode;
   14053    320729460 :   if (VECTOR_MODE_P (mode)
   14054   1658671803 :       && (!targetm.vector_mode_supported_p (mode)
   14055   1313592076 :           || !have_regs_of_mode[mode]))
   14056              :     {
   14057     25307211 :       scalar_int_mode innermode;
   14058              : 
   14059              :       /* For integers, try mapping it to a same-sized scalar mode.  */
   14060     25307211 :       if (is_int_mode (TREE_TYPE (t)->type_common.mode, &innermode))
   14061              :         {
   14062     37565226 :           poly_int64 size = (TYPE_VECTOR_SUBPARTS (t)
   14063     18782613 :                              * GET_MODE_BITSIZE (innermode));
   14064     18782613 :           scalar_int_mode mode;
   14065     33977589 :           if (int_mode_for_size (size, 0).exists (&mode)
   14066     15392147 :               && have_regs_of_mode[mode])
   14067       197171 :             return mode;
   14068              :         }
   14069              : 
   14070              :       return BLKmode;
   14071              :     }
   14072              : 
   14073              :   return mode;
   14074              : }
   14075              : 
   14076              : /* Return the size in bits of each element of vector type TYPE.  */
   14077              : 
   14078              : unsigned int
   14079       254778 : vector_element_bits (const_tree type)
   14080              : {
   14081       254778 :   gcc_checking_assert (VECTOR_TYPE_P (type));
   14082       254778 :   if (VECTOR_BOOLEAN_TYPE_P (type))
   14083         1282 :     return TYPE_PRECISION (TREE_TYPE (type));
   14084       253496 :   return tree_to_uhwi (TYPE_SIZE (TREE_TYPE (type)));
   14085              : }
   14086              : 
   14087              : /* Calculate the size in bits of each element of vector type TYPE
   14088              :    and return the result as a tree of type bitsizetype.  */
   14089              : 
   14090              : tree
   14091       105067 : vector_element_bits_tree (const_tree type)
   14092              : {
   14093       105067 :   gcc_checking_assert (VECTOR_TYPE_P (type));
   14094       105067 :   if (VECTOR_BOOLEAN_TYPE_P (type))
   14095          647 :     return bitsize_int (vector_element_bits (type));
   14096       104420 :   return TYPE_SIZE (TREE_TYPE (type));
   14097              : }
   14098              : 
   14099              : /* Verify that basic properties of T match TV and thus T can be a variant of
   14100              :    TV.  TV should be the more specified variant (i.e. the main variant).  */
   14101              : 
   14102              : static bool
   14103    195634453 : verify_type_variant (const_tree t, tree tv)
   14104              : {
   14105              :   /* Type variant can differ by:
   14106              : 
   14107              :      - TYPE_QUALS: TYPE_READONLY, TYPE_VOLATILE, TYPE_ATOMIC, TYPE_RESTRICT,
   14108              :                    ENCODE_QUAL_ADDR_SPACE.
   14109              :      - main variant may be TYPE_COMPLETE_P and variant types !TYPE_COMPLETE_P
   14110              :        in this case some values may not be set in the variant types
   14111              :        (see TYPE_COMPLETE_P checks).
   14112              :      - it is possible to have TYPE_ARTIFICIAL variant of non-artificial type
   14113              :      - by TYPE_NAME and attributes (i.e. when variant originate by typedef)
   14114              :      - TYPE_CANONICAL (TYPE_ALIAS_SET is the same among variants)
   14115              :      - by the alignment: TYPE_ALIGN and TYPE_USER_ALIGN
   14116              :      - during LTO by TYPE_CONTEXT if type is TYPE_FILE_SCOPE_P
   14117              :        this is necessary to make it possible to merge types form different TUs
   14118              :      - arrays, pointers and references may have TREE_TYPE that is a variant
   14119              :        of TREE_TYPE of their main variants.
   14120              :      - aggregates may have new TYPE_FIELDS list that list variants of
   14121              :        the main variant TYPE_FIELDS.
   14122              :      - vector types may differ by TYPE_VECTOR_OPAQUE
   14123              :    */
   14124              : 
   14125              :   /* Convenience macro for matching individual fields.  */
   14126              : #define verify_variant_match(flag)                                          \
   14127              :   do {                                                                      \
   14128              :     if (flag (tv) != flag (t))                                              \
   14129              :       {                                                                     \
   14130              :         error ("type variant differs by %s", #flag);                      \
   14131              :         debug_tree (tv);                                                    \
   14132              :         return false;                                                       \
   14133              :       }                                                                     \
   14134              :   } while (false)
   14135              : 
   14136              :   /* tree_base checks.  */
   14137              : 
   14138    195634453 :   verify_variant_match (TREE_CODE);
   14139              :   /* FIXME: Ada builds non-artificial variants of artificial types.  */
   14140              : #if 0
   14141              :   if (TYPE_ARTIFICIAL (tv))
   14142              :     verify_variant_match (TYPE_ARTIFICIAL);
   14143              : #endif
   14144    195634453 :   if (POINTER_TYPE_P (tv))
   14145     12807741 :     verify_variant_match (TYPE_REF_CAN_ALIAS_ALL);
   14146              :   /* FIXME: TYPE_SIZES_GIMPLIFIED may differs for Ada build.  */
   14147    195634453 :   verify_variant_match (TYPE_UNSIGNED);
   14148    195634453 :   verify_variant_match (TYPE_PACKED);
   14149    195634453 :   if (TREE_CODE (t) == REFERENCE_TYPE)
   14150      3125829 :     verify_variant_match (TYPE_REF_IS_RVALUE);
   14151    195634453 :   if (AGGREGATE_TYPE_P (t))
   14152     80689841 :     verify_variant_match (TYPE_REVERSE_STORAGE_ORDER);
   14153              :   else
   14154    114944612 :     verify_variant_match (TYPE_SATURATING);
   14155              :   /* FIXME: This check trigger during libstdc++ build.  */
   14156              : #if 0
   14157              :   if (RECORD_OR_UNION_TYPE_P (t) && COMPLETE_TYPE_P (t))
   14158              :     verify_variant_match (TYPE_FINAL_P);
   14159              : #endif
   14160              : 
   14161              :   /* tree_type_common checks.  */
   14162              : 
   14163    195634453 :   if (COMPLETE_TYPE_P (t))
   14164              :     {
   14165    183898601 :       verify_variant_match (TYPE_MODE);
   14166    183898601 :       if (TREE_CODE (TYPE_SIZE (t)) != PLACEHOLDER_EXPR
   14167    183898601 :           && TREE_CODE (TYPE_SIZE (tv)) != PLACEHOLDER_EXPR)
   14168    183898601 :         verify_variant_match (TYPE_SIZE);
   14169    183898601 :       if (TREE_CODE (TYPE_SIZE_UNIT (t)) != PLACEHOLDER_EXPR
   14170    183898601 :           && TREE_CODE (TYPE_SIZE_UNIT (tv)) != PLACEHOLDER_EXPR
   14171    367797202 :           && TYPE_SIZE_UNIT (t) != TYPE_SIZE_UNIT (tv))
   14172              :         {
   14173            0 :           gcc_assert (!operand_equal_p (TYPE_SIZE_UNIT (t),
   14174              :                                         TYPE_SIZE_UNIT (tv), 0));
   14175            0 :           error ("type variant has different %<TYPE_SIZE_UNIT%>");
   14176            0 :           debug_tree (tv);
   14177            0 :           error ("type variant%'s %<TYPE_SIZE_UNIT%>");
   14178            0 :           debug_tree (TYPE_SIZE_UNIT (tv));
   14179            0 :           error ("type%'s %<TYPE_SIZE_UNIT%>");
   14180            0 :           debug_tree (TYPE_SIZE_UNIT (t));
   14181            0 :           return false;
   14182              :         }
   14183    183898601 :       verify_variant_match (TYPE_NEEDS_CONSTRUCTING);
   14184              :     }
   14185    195634453 :   verify_variant_match (TYPE_PRECISION_RAW);
   14186    195634453 :   if (RECORD_OR_UNION_TYPE_P (t))
   14187     80073712 :     verify_variant_match (TYPE_TRANSPARENT_AGGR);
   14188    115560741 :   else if (TREE_CODE (t) == ARRAY_TYPE)
   14189       616129 :     verify_variant_match (TYPE_NONALIASED_COMPONENT);
   14190              :   /* During LTO we merge variant lists from different translation units
   14191              :      that may differ BY TYPE_CONTEXT that in turn may point
   14192              :      to TRANSLATION_UNIT_DECL.
   14193              :      Ada also builds variants of types with different TYPE_CONTEXT.   */
   14194              : #if 0
   14195              :   if (!in_lto_p || !TYPE_FILE_SCOPE_P (t))
   14196              :     verify_variant_match (TYPE_CONTEXT);
   14197              : #endif
   14198    195634453 :   if (TREE_CODE (t) == ARRAY_TYPE || TREE_CODE (t) == INTEGER_TYPE)
   14199     62316969 :     verify_variant_match (TYPE_STRING_FLAG);
   14200    195634453 :   if (TREE_CODE (t) == RECORD_TYPE || TREE_CODE (t) == UNION_TYPE)
   14201     80073712 :     verify_variant_match (TYPE_CXX_ODR_P);
   14202    195634453 :   if (TYPE_ALIAS_SET_KNOWN_P (t))
   14203              :     {
   14204            0 :       error ("type variant with %<TYPE_ALIAS_SET_KNOWN_P%>");
   14205            0 :       debug_tree (tv);
   14206            0 :       return false;
   14207              :     }
   14208              : 
   14209              :   /* tree_type_non_common checks.  */
   14210              : 
   14211              :   /* FIXME: C FE uses TYPE_VFIELD to record C_TYPE_INCOMPLETE_VARS
   14212              :      and dangle the pointer from time to time.  */
   14213     80073712 :   if (RECORD_OR_UNION_TYPE_P (t) && TYPE_VFIELD (t) != TYPE_VFIELD (tv)
   14214    195634453 :       && (in_lto_p || !TYPE_VFIELD (tv)
   14215            0 :           || TREE_CODE (TYPE_VFIELD (tv)) != TREE_LIST))
   14216              :     {
   14217            0 :       error ("type variant has different %<TYPE_VFIELD%>");
   14218            0 :       debug_tree (tv);
   14219            0 :       return false;
   14220              :     }
   14221      3478448 :   if ((TREE_CODE (t) == ENUMERAL_TYPE && COMPLETE_TYPE_P (t))
   14222    192156062 :        || TREE_CODE (t) == INTEGER_TYPE
   14223    130455222 :        || TREE_CODE (t) == BOOLEAN_TYPE
   14224     96190661 :        || TREE_CODE (t) == BITINT_TYPE
   14225     96190247 :        || SCALAR_FLOAT_TYPE_P (t)
   14226    289878434 :        || FIXED_POINT_TYPE_P (t))
   14227              :     {
   14228    101390472 :       verify_variant_match (TYPE_MAX_VALUE);
   14229    101390472 :       verify_variant_match (TYPE_MIN_VALUE);
   14230              :     }
   14231    195634453 :   if (TREE_CODE (t) == METHOD_TYPE)
   14232        11977 :     verify_variant_match (TYPE_METHOD_BASETYPE);
   14233    195634453 :   if (TREE_CODE (t) == OFFSET_TYPE)
   14234         1607 :     verify_variant_match (TYPE_OFFSET_BASETYPE);
   14235    195634453 :   if (TREE_CODE (t) == ARRAY_TYPE)
   14236       616129 :     verify_variant_match (TYPE_ARRAY_MAX_SIZE);
   14237              :   /* FIXME: Be lax and allow TYPE_BINFO to be missing in variant types
   14238              :      or even type's main variant.  This is needed to make bootstrap pass
   14239              :      and the bug seems new in GCC 5.
   14240              :      C++ FE should be updated to make this consistent and we should check
   14241              :      that TYPE_BINFO is always NULL for !COMPLETE_TYPE_P and otherwise there
   14242              :      is a match with main variant.
   14243              : 
   14244              :      Also disable the check for Java for now because of parser hack that builds
   14245              :      first an dummy BINFO and then sometimes replace it by real BINFO in some
   14246              :      of the copies.  */
   14247     80073712 :   if (RECORD_OR_UNION_TYPE_P (t) && TYPE_BINFO (t) && TYPE_BINFO (tv)
   14248     68159754 :       && TYPE_BINFO (t) != TYPE_BINFO (tv)
   14249              :       /* FIXME: Java sometimes keep dump TYPE_BINFOs on variant types.
   14250              :          Since there is no cheap way to tell C++/Java type w/o LTO, do checking
   14251              :          at LTO time only.  */
   14252    195634453 :       && (in_lto_p && odr_type_p (t)))
   14253              :     {
   14254            0 :       error ("type variant has different %<TYPE_BINFO%>");
   14255            0 :       debug_tree (tv);
   14256            0 :       error ("type variant%'s %<TYPE_BINFO%>");
   14257            0 :       debug_tree (TYPE_BINFO (tv));
   14258            0 :       error ("type%'s %<TYPE_BINFO%>");
   14259            0 :       debug_tree (TYPE_BINFO (t));
   14260            0 :       return false;
   14261              :     }
   14262              : 
   14263              :   /* Check various uses of TYPE_VALUES_RAW.  */
   14264    195634453 :   if (TREE_CODE (t) == ENUMERAL_TYPE
   14265    195634453 :       && TYPE_VALUES (t))
   14266      3309263 :     verify_variant_match (TYPE_VALUES);
   14267    192325190 :   else if (TREE_CODE (t) == ARRAY_TYPE)
   14268       616129 :     verify_variant_match (TYPE_DOMAIN);
   14269              :   /* Permit incomplete variants of complete type.  While FEs may complete
   14270              :      all variants, this does not happen for C++ templates in all cases.  */
   14271    191709061 :   else if (RECORD_OR_UNION_TYPE_P (t)
   14272     80073712 :            && COMPLETE_TYPE_P (t)
   14273    260249461 :            && TYPE_FIELDS (t) != TYPE_FIELDS (tv))
   14274              :     {
   14275         4408 :       tree f1, f2;
   14276              : 
   14277              :       /* Fortran builds qualified variants as new records with items of
   14278              :          qualified type. Verify that they looks same.  */
   14279         4408 :       for (f1 = TYPE_FIELDS (t), f2 = TYPE_FIELDS (tv);
   14280        14051 :            f1 && f2;
   14281         9643 :            f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2))
   14282         9643 :         if (TREE_CODE (f1) != FIELD_DECL || TREE_CODE (f2) != FIELD_DECL
   14283         9643 :             || (TYPE_MAIN_VARIANT (TREE_TYPE (f1))
   14284         9643 :                  != TYPE_MAIN_VARIANT (TREE_TYPE (f2))
   14285              :                 /* FIXME: gfc_nonrestricted_type builds all types as variants
   14286              :                    with exception of pointer types.  It deeply copies the type
   14287              :                    which means that we may end up with a variant type
   14288              :                    referring non-variant pointer.  We may change it to
   14289              :                    produce types as variants, too, like
   14290              :                    objc_get_protocol_qualified_type does.  */
   14291           69 :                 && !POINTER_TYPE_P (TREE_TYPE (f1)))
   14292         9643 :             || DECL_FIELD_OFFSET (f1) != DECL_FIELD_OFFSET (f2)
   14293        19286 :             || DECL_FIELD_BIT_OFFSET (f1) != DECL_FIELD_BIT_OFFSET (f2))
   14294              :           break;
   14295         4408 :       if (f1 || f2)
   14296              :         {
   14297            0 :           error ("type variant has different %<TYPE_FIELDS%>");
   14298            0 :           debug_tree (tv);
   14299            0 :           error ("first mismatch is field");
   14300            0 :           debug_tree (f1);
   14301            0 :           error ("and field");
   14302            0 :           debug_tree (f2);
   14303            0 :           return false;
   14304              :         }
   14305              :     }
   14306    191704653 :   else if (FUNC_OR_METHOD_TYPE_P (t))
   14307       151515 :     verify_variant_match (TYPE_ARG_TYPES);
   14308              :   /* For C++ the qualified variant of array type is really an array type
   14309              :      of qualified TREE_TYPE.
   14310              :      objc builds variants of pointer where pointer to type is a variant, too
   14311              :      in objc_get_protocol_qualified_type.  */
   14312    195634453 :   if (TREE_TYPE (t) != TREE_TYPE (tv)
   14313    195634453 :       && ((TREE_CODE (t) != ARRAY_TYPE
   14314            0 :            && !POINTER_TYPE_P (t))
   14315       532448 :           || TYPE_MAIN_VARIANT (TREE_TYPE (t))
   14316       532448 :              != TYPE_MAIN_VARIANT (TREE_TYPE (tv))))
   14317              :     {
   14318            0 :       error ("type variant has different %<TREE_TYPE%>");
   14319            0 :       debug_tree (tv);
   14320            0 :       error ("type variant%'s %<TREE_TYPE%>");
   14321            0 :       debug_tree (TREE_TYPE (tv));
   14322            0 :       error ("type%'s %<TREE_TYPE%>");
   14323            0 :       debug_tree (TREE_TYPE (t));
   14324            0 :       return false;
   14325              :     }
   14326    195634453 :   if (type_with_alias_set_p (t)
   14327    195634453 :       && !gimple_canonical_types_compatible_p (t, tv, false))
   14328              :     {
   14329            0 :       error ("type is not compatible with its variant");
   14330            0 :       debug_tree (tv);
   14331            0 :       error ("type variant%'s %<TREE_TYPE%>");
   14332            0 :       debug_tree (TREE_TYPE (tv));
   14333            0 :       error ("type%'s %<TREE_TYPE%>");
   14334            0 :       debug_tree (TREE_TYPE (t));
   14335            0 :       return false;
   14336              :     }
   14337              :   return true;
   14338              : #undef verify_variant_match
   14339              : }
   14340              : 
   14341              : 
   14342              : /* The TYPE_CANONICAL merging machinery.  It should closely resemble
   14343              :    the middle-end types_compatible_p function.  It needs to avoid
   14344              :    claiming types are different for types that should be treated
   14345              :    the same with respect to TBAA.  Canonical types are also used
   14346              :    for IL consistency checks via the useless_type_conversion_p
   14347              :    predicate which does not handle all type kinds itself but falls
   14348              :    back to pointer-comparison of TYPE_CANONICAL for aggregates
   14349              :    for example.  */
   14350              : 
   14351              : /* Return true if TYPE_UNSIGNED of TYPE should be ignored for canonical
   14352              :    type calculation because we need to allow inter-operability between signed
   14353              :    and unsigned variants.  */
   14354              : 
   14355              : bool
   14356      1728496 : type_with_interoperable_signedness (const_tree type)
   14357              : {
   14358              :   /* Fortran standard require C_SIGNED_CHAR to be interoperable with both
   14359              :      signed char and unsigned char.  Similarly fortran FE builds
   14360              :      C_SIZE_T as signed type, while C defines it unsigned.  */
   14361              : 
   14362      3456011 :   if (tree_code_for_canonical_type_merging (TREE_CODE (type)) == INTEGER_TYPE)
   14363       570805 :     return (TYPE_PRECISION (type) == TYPE_PRECISION (signed_char_type_node)
   14364       570805 :             || TYPE_PRECISION (type) == TYPE_PRECISION (size_type_node));
   14365              : 
   14366              :   /* The C standard allows aliasing between signed and unsigned variants
   14367              :      of the same type.  For INTEGER_TYPEs gimple_get_alias_set handles
   14368              :      this and this works because the integer type cache is pre-loaded
   14369              :      during streaming.  We do not do this for bitint_type_cache, so handle
   14370              :      the aliasing via assigning the same canonical type.  */
   14371      1157691 :   return TREE_CODE (type) == BITINT_TYPE;
   14372              : }
   14373              : 
   14374              : /* Return true iff T1 and T2 are structurally identical for what
   14375              :    TBAA is concerned.
   14376              :    This function is used both by lto.cc canonical type merging and by the
   14377              :    verifier.  If TRUST_TYPE_CANONICAL we do not look into structure of types
   14378              :    that have TYPE_CANONICAL defined and assume them equivalent.  This is useful
   14379              :    only for LTO because only in these cases TYPE_CANONICAL equivalence
   14380              :    correspond to one defined by gimple_canonical_types_compatible_p.  */
   14381              : 
   14382              : bool
   14383    400759152 : gimple_canonical_types_compatible_p (const_tree t1, const_tree t2,
   14384              :                                      bool trust_type_canonical)
   14385              : {
   14386              :   /* Type variants should be same as the main variant.  When not doing sanity
   14387              :      checking to verify this fact, go to main variants and save some work.  */
   14388    401159203 :   if (trust_type_canonical)
   14389              :     {
   14390       925440 :       t1 = TYPE_MAIN_VARIANT (t1);
   14391       925440 :       t2 = TYPE_MAIN_VARIANT (t2);
   14392              :     }
   14393              : 
   14394              :   /* Check first for the obvious case of pointer identity.  */
   14395    401159203 :   if (t1 == t2)
   14396              :     return true;
   14397              : 
   14398              :   /* Check that we have two types to compare.  */
   14399    339042367 :   if (t1 == NULL_TREE || t2 == NULL_TREE)
   14400              :     return false;
   14401              : 
   14402              :   /* We consider complete types always compatible with incomplete type.
   14403              :      This does not make sense for canonical type calculation and thus we
   14404              :      need to ensure that we are never called on it.
   14405              : 
   14406              :      FIXME: For more correctness the function probably should have three modes
   14407              :         1) mode assuming that types are complete matching their structure
   14408              :         2) mode allowing incomplete types but producing equivalence classes
   14409              :            and thus ignoring all info from complete types
   14410              :         3) mode allowing incomplete types to match complete but checking
   14411              :            compatibility between complete types.
   14412              : 
   14413              :      1 and 2 can be used for canonical type calculation. 3 is the real
   14414              :      definition of type compatibility that can be used i.e. for warnings during
   14415              :      declaration merging.  */
   14416              : 
   14417    339042367 :   gcc_assert (!trust_type_canonical
   14418              :               || (type_with_alias_set_p (t1) && type_with_alias_set_p (t2)));
   14419              : 
   14420              :   /* If the types have been previously registered and found equal
   14421              :      they still are.  */
   14422              : 
   14423    677786718 :   if (TYPE_CANONICAL (t1) && TYPE_CANONICAL (t2)
   14424    676812473 :       && trust_type_canonical)
   14425              :     {
   14426              :       /* Do not use TYPE_CANONICAL of pointer types.  For LTO streamed types
   14427              :          they are always NULL, but they are set to non-NULL for types
   14428              :          constructed by build_pointer_type and variants.  In this case the
   14429              :          TYPE_CANONICAL is more fine grained than the equivalnce we test (where
   14430              :          all pointers are considered equal.  Be sure to not return false
   14431              :          negatives.  */
   14432       170784 :       gcc_checking_assert (canonical_type_used_p (t1)
   14433              :                            && canonical_type_used_p (t2));
   14434        85392 :       return TYPE_CANONICAL (t1) == TYPE_CANONICAL (t2);
   14435              :     }
   14436              : 
   14437              :   /* For types where we do ODR based TBAA the canonical type is always
   14438              :      set correctly, so we know that types are different if their
   14439              :      canonical types does not match.  */
   14440    338956975 :   if (trust_type_canonical
   14441    339793959 :       && (odr_type_p (t1) && odr_based_tbaa_p (t1))
   14442       836984 :           != (odr_type_p (t2) && odr_based_tbaa_p (t2)))
   14443              :     return false;
   14444              : 
   14445              :   /* Can't be the same type if the types don't have the same code.  */
   14446    338956975 :   enum tree_code code = tree_code_for_canonical_type_merging (TREE_CODE (t1));
   14447    673741165 :   if (code != tree_code_for_canonical_type_merging (TREE_CODE (t2)))
   14448              :     return false;
   14449              : 
   14450              :   /* Qualifiers do not matter for canonical type comparison purposes.  */
   14451              : 
   14452              :   /* Void types and nullptr types are always the same.  */
   14453    338956940 :   if (VOID_TYPE_P (t1)
   14454    338909244 :       || TREE_CODE (t1) == NULLPTR_TYPE)
   14455              :     return true;
   14456              : 
   14457              :   /* Can't be compatible types if they have different mode.  Because of
   14458              :      flexible array members, we allow mismatching modes for structures or
   14459              :      unions.  */
   14460    338252309 :   if (!RECORD_OR_UNION_TYPE_P (t1)
   14461    338252309 :       && TREE_CODE (t1) != ARRAY_TYPE
   14462    338252309 :       && TYPE_MODE (t1) != TYPE_MODE (t2))
   14463              :     return false;
   14464              : 
   14465              :   /* Non-aggregate types can be handled cheaply.  */
   14466    338252309 :   if (INTEGRAL_TYPE_P (t1)
   14467    338252309 :       || SCALAR_FLOAT_TYPE_P (t1)
   14468    179472776 :       || FIXED_POINT_TYPE_P (t1)
   14469    179089016 :       || VECTOR_TYPE_P (t1)
   14470    179037447 :       || TREE_CODE (t1) == COMPLEX_TYPE
   14471    178688965 :       || TREE_CODE (t1) == OFFSET_TYPE
   14472    178685728 :       || POINTER_TYPE_P (t1))
   14473              :     {
   14474              :       /* Can't be the same type if they have different precision.  */
   14475    202229584 :       if (TYPE_PRECISION_RAW (t1) != TYPE_PRECISION_RAW (t2))
   14476              :         return false;
   14477              : 
   14478              :       /* In some cases the signed and unsigned types are required to be
   14479              :          inter-operable.  */
   14480    202229584 :       if (TYPE_UNSIGNED (t1) != TYPE_UNSIGNED (t2)
   14481    202229584 :           && !type_with_interoperable_signedness (t1))
   14482              :         return false;
   14483              : 
   14484              :       /* Fortran's C_SIGNED_CHAR is !TYPE_STRING_FLAG but needs to be
   14485              :          interoperable with "signed char".  Unless all frontends are revisited
   14486              :          to agree on these types, we must ignore the flag completely.  */
   14487              : 
   14488              :       /* Fortran standard define C_PTR type that is compatible with every
   14489              :          C pointer.  For this reason we need to glob all pointers into one.
   14490              :          Still pointers in different address spaces are not compatible.  */
   14491    202229584 :       if (POINTER_TYPE_P (t1))
   14492              :         {
   14493     42663003 :           if (TYPE_ADDR_SPACE (TREE_TYPE (t1))
   14494     42663003 :               != TYPE_ADDR_SPACE (TREE_TYPE (t2)))
   14495              :             return false;
   14496              :         }
   14497              : 
   14498              :       /* Tail-recurse to components.  */
   14499    202229584 :       if (VECTOR_TYPE_P (t1)
   14500    202229584 :           || TREE_CODE (t1) == COMPLEX_TYPE)
   14501      1200153 :         return gimple_canonical_types_compatible_p (TREE_TYPE (t1),
   14502       400051 :                                                     TREE_TYPE (t2),
   14503       400051 :                                                     trust_type_canonical);
   14504              : 
   14505              :       return true;
   14506              :     }
   14507              : 
   14508              :   /* Do type-specific comparisons.  */
   14509    136022725 :   switch (TREE_CODE (t1))
   14510              :     {
   14511      1111027 :     case ARRAY_TYPE:
   14512              :       /* Array types are the same if the element types are the same and
   14513              :          minimum and maximum index are the same.  */
   14514      1111027 :       if (!gimple_canonical_types_compatible_p (TREE_TYPE (t1), TREE_TYPE (t2),
   14515              :                                                 trust_type_canonical)
   14516      1110984 :           || TYPE_STRING_FLAG (t1) != TYPE_STRING_FLAG (t2)
   14517      1110984 :           || TYPE_REVERSE_STORAGE_ORDER (t1) != TYPE_REVERSE_STORAGE_ORDER (t2)
   14518      2222011 :           || TYPE_NONALIASED_COMPONENT (t1) != TYPE_NONALIASED_COMPONENT (t2))
   14519              :         return false;
   14520              :       else
   14521              :         {
   14522      1110984 :           tree i1 = TYPE_DOMAIN (t1);
   14523      1110984 :           tree i2 = TYPE_DOMAIN (t2);
   14524              : 
   14525              :           /* For an incomplete external array, the type domain can be
   14526              :              NULL_TREE.  Check this condition also.  */
   14527      1110984 :           if (i1 == NULL_TREE && i2 == NULL_TREE)
   14528              :             return true;
   14529      1014231 :           else if (i1 == NULL_TREE || i2 == NULL_TREE)
   14530              :             return false;
   14531              :           else
   14532              :             {
   14533      1014231 :               tree min1 = TYPE_MIN_VALUE (i1);
   14534      1014231 :               tree min2 = TYPE_MIN_VALUE (i2);
   14535      1014231 :               tree max1 = TYPE_MAX_VALUE (i1);
   14536      1014231 :               tree max2 = TYPE_MAX_VALUE (i2);
   14537              : 
   14538              :               /* The minimum/maximum values have to be the same.  */
   14539      1014231 :               if ((min1 == min2
   14540            0 :                    || (min1 && min2
   14541            0 :                        && ((TREE_CODE (min1) == PLACEHOLDER_EXPR
   14542            0 :                             && TREE_CODE (min2) == PLACEHOLDER_EXPR)
   14543            0 :                            || operand_equal_p (min1, min2, 0))))
   14544      1014231 :                   && (max1 == max2
   14545            0 :                       || (max1 && max2
   14546            0 :                           && ((TREE_CODE (max1) == PLACEHOLDER_EXPR
   14547            0 :                                && TREE_CODE (max2) == PLACEHOLDER_EXPR)
   14548            0 :                               || operand_equal_p (max1, max2, 0)))))
   14549      1014231 :                 return true;
   14550              :               else
   14551              :                 return false;
   14552              :             }
   14553              :         }
   14554              : 
   14555         7235 :     case METHOD_TYPE:
   14556         7235 :     case FUNCTION_TYPE:
   14557              :       /* Function types are the same if the return type and arguments types
   14558              :          are the same.  */
   14559         7235 :       if (!gimple_canonical_types_compatible_p (TREE_TYPE (t1), TREE_TYPE (t2),
   14560              :                                                 trust_type_canonical))
   14561              :         return false;
   14562              : 
   14563         7235 :       if (TYPE_ARG_TYPES (t1) == TYPE_ARG_TYPES (t2)
   14564         7235 :           && (TYPE_NO_NAMED_ARGS_STDARG_P (t1)
   14565          340 :               == TYPE_NO_NAMED_ARGS_STDARG_P (t2)))
   14566              :         return true;
   14567              :       else
   14568              :         {
   14569         6895 :           tree parms1, parms2;
   14570              : 
   14571         6895 :           for (parms1 = TYPE_ARG_TYPES (t1), parms2 = TYPE_ARG_TYPES (t2);
   14572        30665 :                parms1 && parms2;
   14573        23770 :                parms1 = TREE_CHAIN (parms1), parms2 = TREE_CHAIN (parms2))
   14574              :             {
   14575        47540 :               if (!gimple_canonical_types_compatible_p
   14576        23770 :                      (TREE_VALUE (parms1), TREE_VALUE (parms2),
   14577              :                       trust_type_canonical))
   14578              :                 return false;
   14579              :             }
   14580              : 
   14581         6895 :           if (parms1 || parms2)
   14582              :             return false;
   14583              : 
   14584         6895 :           return true;
   14585              :         }
   14586              : 
   14587    134558100 :     case RECORD_TYPE:
   14588    134558100 :     case UNION_TYPE:
   14589    134558100 :     case QUAL_UNION_TYPE:
   14590    134558100 :       {
   14591    134558100 :         tree f1, f2;
   14592              : 
   14593              :         /* Don't try to compare variants of an incomplete type, before
   14594              :            TYPE_FIELDS has been copied around.  */
   14595    134558100 :         if (!COMPLETE_TYPE_P (t1) && !COMPLETE_TYPE_P (t2))
   14596              :           return true;
   14597              : 
   14598              : 
   14599    123716618 :         if (TYPE_REVERSE_STORAGE_ORDER (t1) != TYPE_REVERSE_STORAGE_ORDER (t2))
   14600              :           return false;
   14601              : 
   14602              :         /* For aggregate types, all the fields must be the same.  */
   14603    123716618 :         for (f1 = TYPE_FIELDS (t1), f2 = TYPE_FIELDS (t2);
   14604    185550194 :              f1 || f2;
   14605     61833576 :              f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2))
   14606              :           {
   14607              :             /* Skip non-fields and zero-sized fields, except zero-sized
   14608              :                arrays at the end.  */
   14609   1870904267 :             while (f1 && (TREE_CODE (f1) != FIELD_DECL
   14610    113079226 :                           || (DECL_SIZE (f1)
   14611    113061886 :                               && integer_zerop (DECL_SIZE (f1))
   14612     51245627 :                               && (TREE_CHAIN (f1)
   14613         3668 :                                   || TREE_CODE (TREE_TYPE (f1))
   14614              :                                      != ARRAY_TYPE))))
   14615   1686474886 :               f1 = TREE_CHAIN (f1);
   14616   1870905885 :             while (f2 && (TREE_CODE (f2) != FIELD_DECL
   14617    113094513 :                           || (DECL_SIZE (f2)
   14618    113077065 :                               && integer_zerop (DECL_SIZE (f2))
   14619     51247252 :                               && (TREE_CHAIN (f2)
   14620         4777 :                                   || TREE_CODE (TREE_TYPE (f2))
   14621              :                                      != ARRAY_TYPE))))
   14622   1686476504 :               f2 = TREE_CHAIN (f2);
   14623    184429381 :             if (!f1 || !f2)
   14624              :               break;
   14625              : 
   14626     61834371 :             tree t1 = TREE_TYPE (f1);
   14627     61834371 :             tree t2 = TREE_TYPE (f2);
   14628              : 
   14629              :             /* If the last element are arrays, we only compare the element
   14630              :                types.  */
   14631     62945464 :             if (TREE_CHAIN (f1) == NULL_TREE && TREE_CODE (t1) == ARRAY_TYPE
   14632     61922339 :                 && TREE_CHAIN (f2) == NULL_TREE && TREE_CODE (t2) == ARRAY_TYPE)
   14633              :               {
   14634              :                 /* If both arrays have zero size, this is a match.  */
   14635       159004 :                 if (DECL_SIZE (f1) && integer_zerop (DECL_SIZE (f1))
   14636        88735 :                     && DECL_SIZE (f2) && integer_zerop (DECL_SIZE (f2)))
   14637              :                   return true;
   14638              : 
   14639        87192 :                 t1 = TREE_TYPE (t1);
   14640        87192 :                 t2 = TREE_TYPE (t2);
   14641              :               }
   14642              : 
   14643     61833600 :             if (DECL_NONADDRESSABLE_P (f1) != DECL_NONADDRESSABLE_P (f2)
   14644     61833595 :                 || !gimple_compare_field_offset (f1, f2)
   14645    123667195 :                 || !gimple_canonical_types_compatible_p
   14646     61833595 :                       (t1, t2, trust_type_canonical))
   14647              :               return false;
   14648              :           }
   14649              : 
   14650              :         /* If one aggregate has more fields than the other, they
   14651              :            are not the same.  */
   14652    123715823 :         if (f1 || f2)
   14653        13669 :           return false;
   14654              : 
   14655              :         return true;
   14656              :       }
   14657              : 
   14658       346363 :     default:
   14659              :       /* Consider all types with language specific trees in them mutually
   14660              :          compatible.  This is executed only from verify_type and false
   14661              :          positives can be tolerated.  */
   14662       346363 :       gcc_assert (!in_lto_p);
   14663              :       return true;
   14664              :     }
   14665              : }
   14666              : 
   14667              : /* For OPAQUE_TYPE T, it should have only size and alignment information
   14668              :    and its mode should be of class MODE_OPAQUE.  This function verifies
   14669              :    these properties of T match TV which is the main variant of T and TC
   14670              :    which is the canonical of T.  */
   14671              : 
   14672              : static void
   14673          398 : verify_opaque_type (const_tree t, tree tv, tree tc)
   14674              : {
   14675          398 :   gcc_assert (OPAQUE_TYPE_P (t));
   14676          398 :   gcc_assert (tv && tv == TYPE_MAIN_VARIANT (tv));
   14677          398 :   gcc_assert (tc && tc == TYPE_CANONICAL (tc));
   14678              : 
   14679              :   /* For an opaque type T1, check if some of its properties match
   14680              :      the corresponding ones of the other opaque type T2, emit some
   14681              :      error messages for those inconsistent ones.  */
   14682         1089 :   auto check_properties_for_opaque_type = [](const_tree t1, tree t2,
   14683              :                                              const char *kind_msg)
   14684              :   {
   14685          691 :     if (!OPAQUE_TYPE_P (t2))
   14686              :       {
   14687            0 :         error ("type %s is not an opaque type", kind_msg);
   14688            0 :         debug_tree (t2);
   14689            0 :         return;
   14690              :       }
   14691              :     /* For C++ Reflection, we use the opaque type with a scalar integer
   14692              :        mode.  */
   14693          691 :     if (!OPAQUE_MODE_P (TYPE_MODE (t2))
   14694          691 :         && !SCALAR_INT_MODE_P (TYPE_MODE (t2)))
   14695              :       {
   14696            0 :         error ("type %s is not with opaque mode", kind_msg);
   14697            0 :         debug_tree (t2);
   14698            0 :         return;
   14699              :       }
   14700          691 :     if (TYPE_MODE (t1) != TYPE_MODE (t2))
   14701              :       {
   14702            0 :         error ("type %s differs by %<TYPE_MODE%>", kind_msg);
   14703            0 :         debug_tree (t2);
   14704            0 :         return;
   14705              :       }
   14706          691 :     poly_uint64 t1_size = tree_to_poly_uint64 (TYPE_SIZE (t1));
   14707          691 :     poly_uint64 t2_size = tree_to_poly_uint64 (TYPE_SIZE (t2));
   14708          691 :     if (maybe_ne (t1_size, t2_size))
   14709              :       {
   14710            0 :         error ("type %s differs by %<TYPE_SIZE%>", kind_msg);
   14711            0 :         debug_tree (t2);
   14712            0 :         return;
   14713              :       }
   14714          691 :     if (TYPE_ALIGN (t1) != TYPE_ALIGN (t2))
   14715              :       {
   14716            0 :         error ("type %s differs by %<TYPE_ALIGN%>", kind_msg);
   14717            0 :         debug_tree (t2);
   14718            0 :         return;
   14719              :       }
   14720          691 :     if (TYPE_USER_ALIGN (t1) != TYPE_USER_ALIGN (t2))
   14721              :       {
   14722            0 :         error ("type %s differs by %<TYPE_USER_ALIGN%>", kind_msg);
   14723            0 :         debug_tree (t2);
   14724            0 :         return;
   14725              :       }
   14726              :   };
   14727              : 
   14728          398 :   if (t != tv)
   14729          354 :     check_properties_for_opaque_type (t, tv, "variant");
   14730              : 
   14731          398 :   if (t != tc)
   14732          337 :     check_properties_for_opaque_type (t, tc, "canonical");
   14733          398 : }
   14734              : 
   14735              : /* Verify type T.  */
   14736              : 
   14737              : void
   14738    906046603 : verify_type (const_tree t)
   14739              : {
   14740    906046603 :   bool error_found = false;
   14741    906046603 :   tree mv = TYPE_MAIN_VARIANT (t);
   14742    906046603 :   tree ct = TYPE_CANONICAL (t);
   14743              : 
   14744    906046603 :   if (OPAQUE_TYPE_P (t))
   14745              :     {
   14746          398 :       verify_opaque_type (t, mv, ct);
   14747          398 :       return;
   14748              :     }
   14749              : 
   14750    906046205 :   if (!mv)
   14751              :     {
   14752            0 :       error ("main variant is not defined");
   14753            0 :       error_found = true;
   14754              :     }
   14755    906046205 :   else if (mv != TYPE_MAIN_VARIANT (mv))
   14756              :     {
   14757            0 :       error ("%<TYPE_MAIN_VARIANT%> has different %<TYPE_MAIN_VARIANT%>");
   14758            0 :       debug_tree (mv);
   14759            0 :       error_found = true;
   14760              :     }
   14761    906046205 :   else if (t != mv && !verify_type_variant (t, mv))
   14762              :     error_found = true;
   14763              : 
   14764    906046205 :   if (!ct)
   14765              :     ;
   14766    904006289 :   else if (TYPE_CANONICAL (ct) != ct)
   14767              :     {
   14768            0 :       error ("%<TYPE_CANONICAL%> has different %<TYPE_CANONICAL%>");
   14769            0 :       debug_tree (ct);
   14770            0 :       error_found = true;
   14771              :     }
   14772              :   /* Method and function types cannot be used to address memory and thus
   14773              :      TYPE_CANONICAL really matters only for determining useless conversions.
   14774              : 
   14775              :      FIXME: C++ FE produce declarations of builtin functions that are not
   14776              :      compatible with main variants.  */
   14777    904006289 :   else if (TREE_CODE (t) == FUNCTION_TYPE)
   14778              :     ;
   14779    903374922 :   else if (t != ct
   14780              :            /* FIXME: gimple_canonical_types_compatible_p cannot compare types
   14781              :               with variably sized arrays because their sizes possibly
   14782              :               gimplified to different variables.  */
   14783    153111763 :            && !variably_modified_type_p (ct, NULL)
   14784    153106972 :            && !gimple_canonical_types_compatible_p (t, ct, false)
   14785    903388591 :            && COMPLETE_TYPE_P (t))
   14786              :     {
   14787            0 :       error ("%<TYPE_CANONICAL%> is not compatible");
   14788            0 :       debug_tree (ct);
   14789            0 :       error_found = true;
   14790              :     }
   14791   1637883629 :   if (COMPLETE_TYPE_P (t) && TYPE_CANONICAL (t)
   14792              :       /* We allow a mismatch for structure or union because of
   14793              :          flexible array members.  */
   14794    729868249 :       && !RECORD_OR_UNION_TYPE_P (t)
   14795    301006590 :       && !RECORD_OR_UNION_TYPE_P (TYPE_CANONICAL (t))
   14796    301006590 :       && TREE_CODE (t) != ARRAY_TYPE
   14797   1205561036 :       && TYPE_MODE (t) != TYPE_MODE (TYPE_CANONICAL (t)))
   14798              :     {
   14799            0 :       error ("%<TYPE_MODE%> of %<TYPE_CANONICAL%> is not compatible");
   14800            0 :       debug_tree (ct);
   14801            0 :       error_found = true;
   14802              :     }
   14803    906046205 :   if (TYPE_MAIN_VARIANT (t) == t && ct && TYPE_MAIN_VARIANT (ct) != ct)
   14804              :    {
   14805              :      /* This can happen when build_type_attribute_variant is called on
   14806              :         C/C++ arrays of qualified types.  volatile int[2] is unqualified
   14807              :         ARRAY_TYPE with volatile int element type.
   14808              :         TYPE_CANONICAL (volatile int) is itself and so is
   14809              :         TYPE_CANONICAL (volatile int[2]).  build_type_attribute_qual_variant
   14810              :         creates a distinct type copy (so TYPE_MAIN_VARIANT is itself) and sets
   14811              :         its TYPE_CANONICAL to the unqualified ARRAY_TYPE (so volatile int[2]).
   14812              :         But this is not the TYPE_MAIN_VARIANT, which is int[2].  So, just
   14813              :         verify that TYPE_MAIN_VARIANT (ct) is already the final type we
   14814              :         need.  */
   14815            2 :       tree mvc = TYPE_MAIN_VARIANT (ct);
   14816            2 :       if (TYPE_CANONICAL (mvc) != mvc)
   14817              :         {
   14818            0 :           error ("main variant of %<TYPE_CANONICAL%> of main variant is not"
   14819              :                  " its own %<TYPE_CANONICAL%>");
   14820            0 :           debug_tree (ct);
   14821            0 :           debug_tree (TYPE_MAIN_VARIANT (ct));
   14822            0 :           error_found = true;
   14823              :         }
   14824              :    }
   14825              : 
   14826              : 
   14827              :   /* Check various uses of TYPE_MIN_VALUE_RAW.  */
   14828    906046205 :   if (RECORD_OR_UNION_TYPE_P (t))
   14829              :     {
   14830              :       /* FIXME: C FE uses TYPE_VFIELD to record C_TYPE_INCOMPLETE_VARS
   14831              :          and danagle the pointer from time to time.  */
   14832    476346683 :       if (TYPE_VFIELD (t)
   14833     12188628 :           && TREE_CODE (TYPE_VFIELD (t)) != FIELD_DECL
   14834    476346683 :           && TREE_CODE (TYPE_VFIELD (t)) != TREE_LIST)
   14835              :         {
   14836            0 :           error ("%<TYPE_VFIELD%> is not %<FIELD_DECL%> nor %<TREE_LIST%>");
   14837            0 :           debug_tree (TYPE_VFIELD (t));
   14838            0 :           error_found = true;
   14839              :         }
   14840              :     }
   14841    429699522 :   else if (TREE_CODE (t) == POINTER_TYPE)
   14842              :     {
   14843    110431654 :       if (TYPE_NEXT_PTR_TO (t)
   14844    110431654 :           && TREE_CODE (TYPE_NEXT_PTR_TO (t)) != POINTER_TYPE)
   14845              :         {
   14846            0 :           error ("%<TYPE_NEXT_PTR_TO%> is not %<POINTER_TYPE%>");
   14847            0 :           debug_tree (TYPE_NEXT_PTR_TO (t));
   14848            0 :           error_found = true;
   14849              :         }
   14850              :     }
   14851    319267868 :   else if (TREE_CODE (t) == REFERENCE_TYPE)
   14852              :     {
   14853     50472050 :       if (TYPE_NEXT_REF_TO (t)
   14854     50472050 :           && TREE_CODE (TYPE_NEXT_REF_TO (t)) != REFERENCE_TYPE)
   14855              :         {
   14856            0 :           error ("%<TYPE_NEXT_REF_TO%> is not %<REFERENCE_TYPE%>");
   14857            0 :           debug_tree (TYPE_NEXT_REF_TO (t));
   14858            0 :           error_found = true;
   14859              :         }
   14860              :     }
   14861              :   else if (INTEGRAL_TYPE_P (t) || SCALAR_FLOAT_TYPE_P (t)
   14862              :            || FIXED_POINT_TYPE_P (t))
   14863              :     {
   14864              :       /* FIXME: The following check should pass:
   14865              :           useless_type_conversion_p (const_cast <tree> (t),
   14866              :                                      TREE_TYPE (TYPE_MIN_VALUE (t))
   14867              :          but does not for C sizetypes in LTO.  */
   14868              :     }
   14869              : 
   14870              :   /* Check various uses of TYPE_MAXVAL_RAW.  */
   14871    906046205 :   if (RECORD_OR_UNION_TYPE_P (t))
   14872              :     {
   14873    476346683 :       if (!TYPE_BINFO (t))
   14874              :         ;
   14875    447907982 :       else if (TREE_CODE (TYPE_BINFO (t)) != TREE_BINFO)
   14876              :         {
   14877            0 :           error ("%<TYPE_BINFO%> is not %<TREE_BINFO%>");
   14878            0 :           debug_tree (TYPE_BINFO (t));
   14879            0 :           error_found = true;
   14880              :         }
   14881    447907982 :       else if (TREE_TYPE (TYPE_BINFO (t)) != TYPE_MAIN_VARIANT (t))
   14882              :         {
   14883            0 :           error ("%<TYPE_BINFO%> type is not %<TYPE_MAIN_VARIANT%>");
   14884            0 :           debug_tree (TREE_TYPE (TYPE_BINFO (t)));
   14885            0 :           error_found = true;
   14886              :         }
   14887              :     }
   14888              :   else if (FUNC_OR_METHOD_TYPE_P (t))
   14889              :     {
   14890       855365 :       if (TYPE_METHOD_BASETYPE (t)
   14891        70204 :           && TREE_CODE (TYPE_METHOD_BASETYPE (t)) != RECORD_TYPE
   14892       855563 :           && TREE_CODE (TYPE_METHOD_BASETYPE (t)) != UNION_TYPE)
   14893              :         {
   14894            0 :           error ("%<TYPE_METHOD_BASETYPE%> is not record nor union");
   14895            0 :           debug_tree (TYPE_METHOD_BASETYPE (t));
   14896            0 :           error_found = true;
   14897              :         }
   14898              :     }
   14899              :   else if (TREE_CODE (t) == OFFSET_TYPE)
   14900              :     {
   14901        35227 :       if (TYPE_OFFSET_BASETYPE (t)
   14902        35227 :           && TREE_CODE (TYPE_OFFSET_BASETYPE (t)) != RECORD_TYPE
   14903        35235 :           && TREE_CODE (TYPE_OFFSET_BASETYPE (t)) != UNION_TYPE)
   14904              :         {
   14905            0 :           error ("%<TYPE_OFFSET_BASETYPE%> is not record nor union");
   14906            0 :           debug_tree (TYPE_OFFSET_BASETYPE (t));
   14907            0 :           error_found = true;
   14908              :         }
   14909              :     }
   14910              :   else if (INTEGRAL_TYPE_P (t) || SCALAR_FLOAT_TYPE_P (t)
   14911              :            || FIXED_POINT_TYPE_P (t))
   14912              :     {
   14913              :       /* FIXME: The following check should pass:
   14914              :           useless_type_conversion_p (const_cast <tree> (t),
   14915              :                                      TREE_TYPE (TYPE_MAX_VALUE (t))
   14916              :          but does not for C sizetypes in LTO.  */
   14917              :     }
   14918              :   else if (TREE_CODE (t) == ARRAY_TYPE)
   14919              :     {
   14920      1763255 :       if (TYPE_ARRAY_MAX_SIZE (t)
   14921      1763255 :           && TREE_CODE (TYPE_ARRAY_MAX_SIZE (t)) != INTEGER_CST)
   14922              :         {
   14923            0 :           error ("%<TYPE_ARRAY_MAX_SIZE%> not %<INTEGER_CST%>");
   14924            0 :           debug_tree (TYPE_ARRAY_MAX_SIZE (t));
   14925            0 :           error_found = true;
   14926              :         }
   14927              :     }
   14928    288888199 :   else if (TYPE_MAX_VALUE_RAW (t))
   14929              :     {
   14930            0 :       error ("%<TYPE_MAX_VALUE_RAW%> non-NULL");
   14931            0 :       debug_tree (TYPE_MAX_VALUE_RAW (t));
   14932            0 :       error_found = true;
   14933              :     }
   14934              : 
   14935    906046205 :   if (TYPE_LANG_SLOT_1 (t) && in_lto_p)
   14936              :     {
   14937            0 :       error ("%<TYPE_LANG_SLOT_1 (binfo)%> field is non-NULL");
   14938            0 :       debug_tree (TYPE_LANG_SLOT_1 (t));
   14939            0 :       error_found = true;
   14940              :     }
   14941              : 
   14942              :   /* Check various uses of TYPE_VALUES_RAW.  */
   14943    906046205 :   if (TREE_CODE (t) == ENUMERAL_TYPE)
   14944    102573927 :     for (tree l = TYPE_VALUES (t); l; l = TREE_CHAIN (l))
   14945              :       {
   14946     89183624 :         tree value = TREE_VALUE (l);
   14947     89183624 :         tree name = TREE_PURPOSE (l);
   14948              : 
   14949              :         /* C FE porduce INTEGER_CST of INTEGER_TYPE, while C++ FE uses
   14950              :            CONST_DECL of ENUMERAL TYPE.  */
   14951     89183624 :         if (TREE_CODE (value) != INTEGER_CST && TREE_CODE (value) != CONST_DECL)
   14952              :           {
   14953            0 :             error ("enum value is not %<CONST_DECL%> or %<INTEGER_CST%>");
   14954            0 :             debug_tree (value);
   14955            0 :             debug_tree (name);
   14956            0 :             error_found = true;
   14957              :           }
   14958     89183624 :         if (TREE_CODE (TREE_TYPE (value)) != INTEGER_TYPE
   14959     89166490 :             && TREE_CODE (TREE_TYPE (value)) != BOOLEAN_TYPE
   14960    178350111 :             && !useless_type_conversion_p (const_cast <tree> (t), TREE_TYPE (value)))
   14961              :           {
   14962            0 :             error ("enum value type is not %<INTEGER_TYPE%> nor convertible "
   14963              :                    "to the enum");
   14964            0 :             debug_tree (value);
   14965            0 :             debug_tree (name);
   14966            0 :             error_found = true;
   14967              :           }
   14968     89183624 :         if (TREE_CODE (name) != IDENTIFIER_NODE)
   14969              :           {
   14970            0 :             error ("enum value name is not %<IDENTIFIER_NODE%>");
   14971            0 :             debug_tree (value);
   14972            0 :             debug_tree (name);
   14973            0 :             error_found = true;
   14974              :           }
   14975              :       }
   14976    892655902 :   else if (TREE_CODE (t) == ARRAY_TYPE)
   14977              :     {
   14978      1763255 :       if (TYPE_DOMAIN (t) && TREE_CODE (TYPE_DOMAIN (t)) != INTEGER_TYPE)
   14979              :         {
   14980            0 :           error ("array %<TYPE_DOMAIN%> is not integer type");
   14981            0 :           debug_tree (TYPE_DOMAIN (t));
   14982            0 :           error_found = true;
   14983              :         }
   14984              :     }
   14985    890892647 :   else if (RECORD_OR_UNION_TYPE_P (t))
   14986              :     {
   14987    476346683 :       if (TYPE_FIELDS (t) && !COMPLETE_TYPE_P (t) && in_lto_p)
   14988              :         {
   14989            0 :           error ("%<TYPE_FIELDS%> defined in incomplete type");
   14990            0 :           error_found = true;
   14991              :         }
   14992  20549160152 :       for (tree fld = TYPE_FIELDS (t); fld; fld = TREE_CHAIN (fld))
   14993              :         {
   14994              :           /* TODO: verify properties of decls.  */
   14995  20072813469 :           if (TREE_CODE (fld) == FIELD_DECL)
   14996              :             ;
   14997              :           else if (TREE_CODE (fld) == TYPE_DECL)
   14998              :             ;
   14999              :           else if (TREE_CODE (fld) == CONST_DECL)
   15000              :             ;
   15001              :           else if (VAR_P (fld))
   15002              :             ;
   15003              :           else if (TREE_CODE (fld) == TEMPLATE_DECL)
   15004              :             ;
   15005              :           else if (TREE_CODE (fld) == USING_DECL)
   15006              :             ;
   15007              :           else if (TREE_CODE (fld) == FUNCTION_DECL)
   15008              :             ;
   15009              :           else
   15010              :             {
   15011            0 :               error ("wrong tree in %<TYPE_FIELDS%> list");
   15012            0 :               debug_tree (fld);
   15013            0 :               error_found = true;
   15014              :             }
   15015              :         }
   15016              :     }
   15017    414545964 :   else if (TREE_CODE (t) == INTEGER_TYPE
   15018              :            || TREE_CODE (t) == BOOLEAN_TYPE
   15019    414545964 :            || TREE_CODE (t) == BITINT_TYPE
   15020    295066991 :            || TREE_CODE (t) == OFFSET_TYPE
   15021    295031764 :            || TREE_CODE (t) == REFERENCE_TYPE
   15022    244559714 :            || TREE_CODE (t) == NULLPTR_TYPE
   15023    244215778 :            || TREE_CODE (t) == POINTER_TYPE)
   15024              :     {
   15025    280761840 :       if (TYPE_CACHED_VALUES_P (t) != (TYPE_CACHED_VALUES (t) != NULL))
   15026              :         {
   15027            0 :           error ("%<TYPE_CACHED_VALUES_P%> is %i while %<TYPE_CACHED_VALUES%> "
   15028              :                  "is %p",
   15029            0 :                  TYPE_CACHED_VALUES_P (t), (void *)TYPE_CACHED_VALUES (t));
   15030            0 :           error_found = true;
   15031              :         }
   15032    280761840 :       else if (TYPE_CACHED_VALUES_P (t) && TREE_CODE (TYPE_CACHED_VALUES (t)) != TREE_VEC)
   15033              :         {
   15034            0 :           error ("%<TYPE_CACHED_VALUES%> is not %<TREE_VEC%>");
   15035            0 :           debug_tree (TYPE_CACHED_VALUES (t));
   15036            0 :           error_found = true;
   15037              :         }
   15038              :       /* Verify just enough of cache to ensure that no one copied it to new type.
   15039              :          All copying should go by copy_node that should clear it.  */
   15040    280761840 :       else if (TYPE_CACHED_VALUES_P (t))
   15041              :         {
   15042              :           int i;
   15043   8364487541 :           for (i = 0; i < TREE_VEC_LENGTH (TYPE_CACHED_VALUES (t)); i++)
   15044   8298909229 :             if (TREE_VEC_ELT (TYPE_CACHED_VALUES (t), i)
   15045   8298909229 :                 && TREE_TYPE (TREE_VEC_ELT (TYPE_CACHED_VALUES (t), i)) != t)
   15046              :               {
   15047            0 :                 error ("wrong %<TYPE_CACHED_VALUES%> entry");
   15048            0 :                 debug_tree (TREE_VEC_ELT (TYPE_CACHED_VALUES (t), i));
   15049            0 :                 error_found = true;
   15050            0 :                 break;
   15051              :               }
   15052              :         }
   15053              :     }
   15054    133784124 :   else if (FUNC_OR_METHOD_TYPE_P (t))
   15055      3230531 :     for (tree l = TYPE_ARG_TYPES (t); l; l = TREE_CHAIN (l))
   15056              :       {
   15057              :         /* C++ FE uses TREE_PURPOSE to store initial values.  */
   15058      2375166 :         if (TREE_PURPOSE (l) && in_lto_p)
   15059              :           {
   15060            0 :             error ("%<TREE_PURPOSE%> is non-NULL in %<TYPE_ARG_TYPES%> list");
   15061            0 :             debug_tree (l);
   15062            0 :             error_found = true;
   15063              :           }
   15064      2375166 :         if (!TYPE_P (TREE_VALUE (l)))
   15065              :           {
   15066            0 :             error ("wrong entry in %<TYPE_ARG_TYPES%> list");
   15067            0 :             debug_tree (l);
   15068            0 :             error_found = true;
   15069              :           }
   15070              :       }
   15071    265480688 :   else if (!is_lang_specific (t) && TYPE_VALUES_RAW (t))
   15072              :     {
   15073            0 :       error ("%<TYPE_VALUES_RAW%> field is non-NULL");
   15074            0 :       debug_tree (TYPE_VALUES_RAW (t));
   15075            0 :       error_found = true;
   15076              :     }
   15077    906046205 :   if (TREE_CODE (t) != INTEGER_TYPE
   15078              :       && TREE_CODE (t) != BOOLEAN_TYPE
   15079    906046205 :       && TREE_CODE (t) != BITINT_TYPE
   15080              :       && TREE_CODE (t) != OFFSET_TYPE
   15081              :       && TREE_CODE (t) != REFERENCE_TYPE
   15082              :       && TREE_CODE (t) != NULLPTR_TYPE
   15083              :       && TREE_CODE (t) != POINTER_TYPE
   15084    625284365 :       && TYPE_CACHED_VALUES_P (t))
   15085              :     {
   15086            0 :       error ("%<TYPE_CACHED_VALUES_P%> is set while it should not be");
   15087            0 :       error_found = true;
   15088              :     }
   15089              : 
   15090              :   /* ipa-devirt makes an assumption that TYPE_METHOD_BASETYPE is always
   15091              :      TYPE_MAIN_VARIANT and it would be odd to add methods only to variatns
   15092              :      of a type. */
   15093    906046205 :   if (TREE_CODE (t) == METHOD_TYPE
   15094    906046205 :       && TYPE_MAIN_VARIANT (TYPE_METHOD_BASETYPE (t)) != TYPE_METHOD_BASETYPE (t))
   15095              :     {
   15096            0 :         error ("%<TYPE_METHOD_BASETYPE%> is not main variant");
   15097            0 :         error_found = true;
   15098              :     }
   15099              : 
   15100    906046205 :   if (error_found)
   15101              :     {
   15102            0 :       debug_tree (const_cast <tree> (t));
   15103            0 :       internal_error ("%qs failed", __func__);
   15104              :     }
   15105              : }
   15106              : 
   15107              : 
   15108              : /* Return 1 if ARG interpreted as signed in its precision is known to be
   15109              :    always non-negative or 2 if ARG is known to be always negative, or 3 if
   15110              :    ARG may be non-negative or negative.  STMT if specified is the statement
   15111              :    on which it is being tested.  */
   15112              : 
   15113              : int
   15114       881665 : get_range_pos_neg (tree arg, gimple *stmt)
   15115              : {
   15116       881665 :   if (arg == error_mark_node || !INTEGRAL_TYPE_P (TREE_TYPE (arg)))
   15117              :     return 3;
   15118              : 
   15119       881665 :   int prec = TYPE_PRECISION (TREE_TYPE (arg));
   15120       881665 :   int cnt = 0;
   15121       881665 :   if (TREE_CODE (arg) == INTEGER_CST)
   15122              :     {
   15123        68599 :       wide_int w = wi::sext (wi::to_wide (arg), prec);
   15124        68599 :       if (wi::neg_p (w))
   15125              :         return 2;
   15126              :       else
   15127        54179 :         return 1;
   15128        68599 :     }
   15129       811398 :   while (CONVERT_EXPR_P (arg)
   15130        15401 :          && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (arg, 0)))
   15131       842200 :          && TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (arg, 0))) <= prec)
   15132              :     {
   15133        14757 :       arg = TREE_OPERAND (arg, 0);
   15134              :       /* Narrower value zero extended into wider type
   15135              :          will always result in positive values.  */
   15136        14757 :       if (TYPE_UNSIGNED (TREE_TYPE (arg))
   15137        14757 :           && TYPE_PRECISION (TREE_TYPE (arg)) < prec)
   15138              :         return 1;
   15139        13733 :       prec = TYPE_PRECISION (TREE_TYPE (arg));
   15140        13733 :       if (++cnt > 30)
   15141              :         return 3;
   15142              :     }
   15143              : 
   15144       812042 :   if (TREE_CODE (arg) != SSA_NAME)
   15145              :     return 3;
   15146       805768 :   int_range_max r;
   15147      1630734 :   while (!get_range_query (cfun)->range_of_expr (r, arg, stmt)
   15148      1649932 :          || r.undefined_p () || r.varying_p ())
   15149              :     {
   15150       543595 :       gimple *g = SSA_NAME_DEF_STMT (arg);
   15151       543595 :       if (is_gimple_assign (g)
   15152       543595 :           && CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (g)))
   15153              :         {
   15154        31224 :           tree t = gimple_assign_rhs1 (g);
   15155        62121 :           if (INTEGRAL_TYPE_P (TREE_TYPE (t))
   15156        59427 :               && TYPE_PRECISION (TREE_TYPE (t)) <= prec)
   15157              :             {
   15158        21599 :               if (TYPE_UNSIGNED (TREE_TYPE (t))
   15159        21599 :                   && TYPE_PRECISION (TREE_TYPE (t)) < prec)
   15160              :                 return 1;
   15161        19198 :               prec = TYPE_PRECISION (TREE_TYPE (t));
   15162        19198 :               arg = t;
   15163        19198 :               if (++cnt > 30)
   15164              :                 return 3;
   15165        19198 :               continue;
   15166              :             }
   15167              :         }
   15168              :       return 3;
   15169              :     }
   15170       281371 :   if (TYPE_UNSIGNED (TREE_TYPE (arg)))
   15171              :     {
   15172              :       /* For unsigned values, the "positive" range comes
   15173              :          below the "negative" range.  */
   15174       115720 :       if (!wi::neg_p (wi::sext (r.upper_bound (), prec), SIGNED))
   15175              :         return 1;
   15176        32531 :       if (wi::neg_p (wi::sext (r.lower_bound (), prec), SIGNED))
   15177          847 :         return 2;
   15178              :     }
   15179              :   else
   15180              :     {
   15181       165651 :       if (!wi::neg_p (wi::sext (r.lower_bound (), prec), SIGNED))
   15182              :         return 1;
   15183        66008 :       if (wi::neg_p (wi::sext (r.upper_bound (), prec), SIGNED))
   15184         1226 :         return 2;
   15185              :     }
   15186              :   return 3;
   15187       805768 : }
   15188              : 
   15189              : 
   15190              : 
   15191              : 
   15192              : /* Return true if ARG is marked with the nonnull attribute in the
   15193              :    current function signature.  */
   15194              : 
   15195              : bool
   15196     29073888 : nonnull_arg_p (const_tree arg)
   15197              : {
   15198     29073888 :   tree t, attrs, fntype;
   15199     29073888 :   unsigned HOST_WIDE_INT arg_num;
   15200              : 
   15201     29073888 :   gcc_assert (TREE_CODE (arg) == PARM_DECL
   15202              :               && (POINTER_TYPE_P (TREE_TYPE (arg))
   15203              :                   || TREE_CODE (TREE_TYPE (arg)) == OFFSET_TYPE));
   15204              : 
   15205              :   /* The static chain decl is always non null.  */
   15206     29073888 :   if (arg == cfun->static_chain_decl)
   15207              :     return true;
   15208              : 
   15209              :   /* THIS argument of method is always non-NULL.  */
   15210     28804540 :   if (TREE_CODE (TREE_TYPE (cfun->decl)) == METHOD_TYPE
   15211     11529182 :       && arg == DECL_ARGUMENTS (cfun->decl)
   15212     36235332 :       && flag_delete_null_pointer_checks)
   15213              :     return true;
   15214              : 
   15215              :   /* Values passed by reference are always non-NULL.  */
   15216     21376203 :   if (TREE_CODE (TREE_TYPE (arg)) == REFERENCE_TYPE
   15217     21376203 :       && flag_delete_null_pointer_checks)
   15218              :     return true;
   15219              : 
   15220     14000172 :   fntype = TREE_TYPE (cfun->decl);
   15221     14024074 :   for (attrs = TYPE_ATTRIBUTES (fntype); attrs; attrs = TREE_CHAIN (attrs))
   15222              :     {
   15223       570719 :       attrs = lookup_attribute ("nonnull", attrs);
   15224              : 
   15225              :       /* If "nonnull" wasn't specified, we know nothing about the argument.  */
   15226       570719 :       if (attrs == NULL_TREE)
   15227              :         return false;
   15228              : 
   15229              :       /* If "nonnull" applies to all the arguments, then ARG is non-null.  */
   15230       113851 :       if (TREE_VALUE (attrs) == NULL_TREE)
   15231              :         return true;
   15232              : 
   15233              :       /* Get the position number for ARG in the function signature.  */
   15234        57029 :       for (arg_num = 1, t = DECL_ARGUMENTS (cfun->decl);
   15235       131441 :            t;
   15236        74412 :            t = DECL_CHAIN (t), arg_num++)
   15237              :         {
   15238       131441 :           if (t == arg)
   15239              :             break;
   15240              :         }
   15241              : 
   15242        57029 :       gcc_assert (t == arg);
   15243              : 
   15244              :       /* Now see if ARG_NUM is mentioned in the nonnull list.  */
   15245        90598 :       for (t = TREE_VALUE (attrs); t; t = TREE_CHAIN (t))
   15246              :         {
   15247        66696 :           if (compare_tree_int (TREE_VALUE (t), arg_num) == 0)
   15248              :             return true;
   15249              :         }
   15250              :     }
   15251              : 
   15252              :   return false;
   15253              : }
   15254              : 
   15255              : /* Combine LOC and BLOCK to a combined adhoc loc, retaining any range
   15256              :    information.  */
   15257              : 
   15258              : location_t
   15259    949863808 : set_block (location_t loc, tree block)
   15260              : {
   15261    949863808 :   location_t pure_loc = get_pure_location (loc);
   15262    949863808 :   source_range src_range = get_range_from_loc (line_table, loc);
   15263    949863808 :   unsigned discriminator = get_discriminator_from_loc (line_table, loc);
   15264    949863808 :   return line_table->get_or_create_combined_loc (pure_loc, src_range, block,
   15265    949863808 :                                                  discriminator);
   15266              : }
   15267              : 
   15268              : location_t
   15269    230813186 : set_source_range (tree expr, location_t start, location_t finish)
   15270              : {
   15271    230813186 :   source_range src_range;
   15272    230813186 :   src_range.m_start = start;
   15273    230813186 :   src_range.m_finish = finish;
   15274    230813186 :   return set_source_range (expr, src_range);
   15275              : }
   15276              : 
   15277              : location_t
   15278    469506231 : set_source_range (tree expr, source_range src_range)
   15279              : {
   15280    469506231 :   if (!EXPR_P (expr))
   15281              :     return UNKNOWN_LOCATION;
   15282              : 
   15283    206498627 :   location_t expr_location = EXPR_LOCATION (expr);
   15284    206498627 :   location_t pure_loc = get_pure_location (expr_location);
   15285    206498627 :   unsigned discriminator = get_discriminator_from_loc (expr_location);
   15286    206498627 :   location_t adhoc = line_table->get_or_create_combined_loc (pure_loc,
   15287              :                                                              src_range,
   15288              :                                                              nullptr,
   15289              :                                                              discriminator);
   15290    206498627 :   SET_EXPR_LOCATION (expr, adhoc);
   15291    206498627 :   return adhoc;
   15292              : }
   15293              : 
   15294              : /* Return EXPR, potentially wrapped with a node expression LOC,
   15295              :    if !CAN_HAVE_LOCATION_P (expr).
   15296              : 
   15297              :    NON_LVALUE_EXPR is used for wrapping constants, apart from STRING_CST.
   15298              :    VIEW_CONVERT_EXPR is used for wrapping non-constants and STRING_CST.
   15299              : 
   15300              :    Wrapper nodes can be identified using location_wrapper_p.  */
   15301              : 
   15302              : tree
   15303   1598844315 : maybe_wrap_with_location (tree expr, location_t loc)
   15304              : {
   15305   1598844315 :   if (expr == NULL)
   15306              :     return NULL;
   15307   1598844311 :   if (loc == UNKNOWN_LOCATION)
   15308              :     return expr;
   15309   1544482998 :   if (CAN_HAVE_LOCATION_P (expr))
   15310              :     return expr;
   15311              :   /* We should only be adding wrappers for constants and for decls,
   15312              :      or for some exceptional tree nodes (e.g. BASELINK in the C++ FE).  */
   15313    945425842 :   gcc_assert (CONSTANT_CLASS_P (expr)
   15314              :               || DECL_P (expr)
   15315              :               || EXCEPTIONAL_CLASS_P (expr));
   15316              : 
   15317              :   /* For now, don't add wrappers to exceptional tree nodes, to minimize
   15318              :      any impact of the wrapper nodes.  */
   15319    945425842 :   if (EXCEPTIONAL_CLASS_P (expr) || error_operand_p (expr))
   15320              :     return expr;
   15321              : 
   15322              :   /* Compiler-generated temporary variables don't need a wrapper.  */
   15323    871678113 :   if (DECL_P (expr) && DECL_ARTIFICIAL (expr) && DECL_IGNORED_P (expr))
   15324              :     return expr;
   15325              : 
   15326              :   /* If any auto_suppress_location_wrappers are active, don't create
   15327              :      wrappers.  */
   15328    871675583 :   if (suppress_location_wrappers > 0)
   15329              :     return expr;
   15330              : 
   15331   1629589220 :   tree_code code
   15332    213653898 :     = (((CONSTANT_CLASS_P (expr) && TREE_CODE (expr) != STRING_CST)
   15333    610042984 :         || (TREE_CODE (expr) == CONST_DECL && !TREE_STATIC (expr)))
   15334    814794610 :        ? NON_LVALUE_EXPR : VIEW_CONVERT_EXPR);
   15335    814794610 :   tree wrapper = build1_loc (loc, code, TREE_TYPE (expr), expr);
   15336              :   /* Mark this node as being a wrapper.  */
   15337    814794610 :   EXPR_LOCATION_WRAPPER_P (wrapper) = 1;
   15338    814794610 :   return wrapper;
   15339              : }
   15340              : 
   15341              : int suppress_location_wrappers;
   15342              : 
   15343              : /* Return the name of combined function FN, for debugging purposes.  */
   15344              : 
   15345              : const char *
   15346            0 : combined_fn_name (combined_fn fn)
   15347              : {
   15348            0 :   if (builtin_fn_p (fn))
   15349              :     {
   15350            0 :       tree fndecl = builtin_decl_explicit (as_builtin_fn (fn));
   15351            0 :       return IDENTIFIER_POINTER (DECL_NAME (fndecl));
   15352              :     }
   15353              :   else
   15354            0 :     return internal_fn_name (as_internal_fn (fn));
   15355              : }
   15356              : 
   15357              : /* Return a bitmap with a bit set corresponding to each argument in
   15358              :    a function call type FNTYPE declared with attribute nonnull,
   15359              :    or null if none of the function's argument are nonnull.  The caller
   15360              :    must free the bitmap.  */
   15361              : 
   15362              : bitmap
   15363     22026739 : get_nonnull_args (const_tree fntype)
   15364              : {
   15365     22026739 :   if (fntype == NULL_TREE)
   15366              :     return NULL;
   15367              : 
   15368     21359325 :   bitmap argmap = NULL;
   15369     21359325 :   if (TREE_CODE (fntype) == METHOD_TYPE)
   15370              :     {
   15371              :       /* The this pointer in C++ non-static member functions is
   15372              :          implicitly nonnull whether or not it's declared as such.  */
   15373      2829420 :       argmap = BITMAP_ALLOC (NULL);
   15374      2829420 :       bitmap_set_bit (argmap, 0);
   15375              :     }
   15376              : 
   15377     21359325 :   tree attrs = TYPE_ATTRIBUTES (fntype);
   15378     21359325 :   if (!attrs)
   15379              :     return argmap;
   15380              : 
   15381              :   /* A function declaration can specify multiple attribute nonnull,
   15382              :      each with zero or more arguments.  The loop below creates a bitmap
   15383              :      representing a union of all the arguments.  An empty (but non-null)
   15384              :      bitmap means that all arguments have been declared nonnull.  */
   15385      5913997 :   for ( ; attrs; attrs = TREE_CHAIN (attrs))
   15386              :     {
   15387      5808082 :       attrs = lookup_attribute ("nonnull", attrs);
   15388      5808082 :       if (!attrs)
   15389              :         break;
   15390              : 
   15391      1421270 :       if (!argmap)
   15392      1382871 :         argmap = BITMAP_ALLOC (NULL);
   15393              : 
   15394      1421270 :       if (!TREE_VALUE (attrs))
   15395              :         {
   15396              :           /* Clear the bitmap in case a previous attribute nonnull
   15397              :              set it and this one overrides it for all arguments.  */
   15398       772952 :           bitmap_clear (argmap);
   15399       772952 :           return argmap;
   15400              :         }
   15401              : 
   15402              :       /* Iterate over the indices of the format arguments declared nonnull
   15403              :          and set a bit for each.  */
   15404      1704605 :       for (tree idx = TREE_VALUE (attrs); idx; idx = TREE_CHAIN (idx))
   15405              :         {
   15406      1056287 :           unsigned int val = TREE_INT_CST_LOW (TREE_VALUE (idx)) - 1;
   15407      1056287 :           bitmap_set_bit (argmap, val);
   15408              :         }
   15409              :     }
   15410              : 
   15411              :   return argmap;
   15412              : }
   15413              : 
   15414              : /* Returns true if TYPE is a type where it and all of its subobjects
   15415              :    (recursively) are of structure, union, or array type.  */
   15416              : 
   15417              : bool
   15418   2021623858 : is_empty_type (const_tree type)
   15419              : {
   15420   2021623858 :   if (RECORD_OR_UNION_TYPE_P (type))
   15421              :     {
   15422    887955190 :       for (tree field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
   15423    815597591 :         if (TREE_CODE (field) == FIELD_DECL
   15424    405385291 :             && !DECL_PADDING_P (field)
   15425   1220981536 :             && !is_empty_type (TREE_TYPE (field)))
   15426              :           return false;
   15427              :       return true;
   15428              :     }
   15429   1572340862 :   else if (TREE_CODE (type) == ARRAY_TYPE)
   15430     88489953 :     return (integer_minus_onep (array_type_nelts_minus_one (type))
   15431     88445743 :             || TYPE_DOMAIN (type) == NULL_TREE
   15432    166759691 :             || is_empty_type (TREE_TYPE (type)));
   15433              :   return false;
   15434              : }
   15435              : 
   15436              : /* Implement TARGET_EMPTY_RECORD_P.  Return true if TYPE is an empty type
   15437              :    that shouldn't be passed via stack.  */
   15438              : 
   15439              : bool
   15440   1485399181 : default_is_empty_record (const_tree type)
   15441              : {
   15442   1485399181 :   if (!abi_version_at_least (12))
   15443              :     return false;
   15444              : 
   15445   1484333997 :   if (type == error_mark_node)
   15446              :     return false;
   15447              : 
   15448   1484333997 :   if (TREE_ADDRESSABLE (type))
   15449              :     return false;
   15450              : 
   15451   1484333997 :   return is_empty_type (TYPE_MAIN_VARIANT (type));
   15452              : }
   15453              : 
   15454              : 
   15455              : /* Determine whether TYPE is an ISO C99 flexible array member type "[]".  */
   15456              : 
   15457              : bool
   15458     11886503 : flexible_array_member_type_p (const_tree type)
   15459              : {
   15460     11886503 :   if (TREE_CODE (type) == ARRAY_TYPE
   15461      4965071 :       && TYPE_SIZE (type) == NULL_TREE
   15462       650159 :       && TYPE_DOMAIN (type) != NULL_TREE
   15463     12445923 :       && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL_TREE)
   15464       559420 :     return true;
   15465              : 
   15466              :   return false;
   15467              : }
   15468              : 
   15469              : 
   15470              : /* Determine whether TYPE is a structure with a flexible array member,
   15471              :    or a union containing such a structure (possibly recursively).  */
   15472              : 
   15473              : bool
   15474        72705 : flexible_array_type_p (const_tree type)
   15475              : {
   15476        72705 :   tree x, last;
   15477        72705 :   switch (TREE_CODE (type))
   15478              :     {
   15479        38389 :     case RECORD_TYPE:
   15480        38389 :       last = NULL_TREE;
   15481       174557 :       for (x = TYPE_FIELDS (type); x != NULL_TREE; x = DECL_CHAIN (x))
   15482       136168 :         if (TREE_CODE (x) == FIELD_DECL)
   15483       136168 :           last = x;
   15484        38389 :       if (last == NULL_TREE)
   15485              :         return false;
   15486        38381 :        return flexible_array_member_type_p (TREE_TYPE (last));
   15487          579 :     case UNION_TYPE:
   15488         1668 :       for (x = TYPE_FIELDS (type); x != NULL_TREE; x = DECL_CHAIN (x))
   15489              :         {
   15490         1131 :           if (TREE_CODE (x) == FIELD_DECL
   15491         1131 :               && flexible_array_type_p (TREE_TYPE (x)))
   15492              :             return true;
   15493              :         }
   15494              :       return false;
   15495              :     default:
   15496              :       return false;
   15497              :   }
   15498              : }
   15499              : 
   15500              : /* Like int_size_in_bytes, but handle empty records specially.  */
   15501              : 
   15502              : HOST_WIDE_INT
   15503       464012 : arg_int_size_in_bytes (const_tree type)
   15504              : {
   15505       464012 :   return TYPE_EMPTY_P (type) ? 0 : int_size_in_bytes (type);
   15506              : }
   15507              : 
   15508              : /* Like size_in_bytes, but handle empty records specially.  */
   15509              : 
   15510              : tree
   15511      5730945 : arg_size_in_bytes (const_tree type)
   15512              : {
   15513      5730945 :   return TYPE_EMPTY_P (type) ? size_zero_node : size_in_bytes (type);
   15514              : }
   15515              : 
   15516              : /* Return true if an expression with CODE has to have the same result type as
   15517              :    its first operand.  */
   15518              : 
   15519              : bool
   15520            0 : expr_type_first_operand_type_p (tree_code code)
   15521              : {
   15522            0 :   switch (code)
   15523              :     {
   15524              :     case NEGATE_EXPR:
   15525              :     case ABS_EXPR:
   15526              :     case BIT_NOT_EXPR:
   15527              :     case PAREN_EXPR:
   15528              :     case CONJ_EXPR:
   15529              : 
   15530              :     case PLUS_EXPR:
   15531              :     case MINUS_EXPR:
   15532              :     case MULT_EXPR:
   15533              :     case TRUNC_DIV_EXPR:
   15534              :     case CEIL_DIV_EXPR:
   15535              :     case FLOOR_DIV_EXPR:
   15536              :     case ROUND_DIV_EXPR:
   15537              :     case TRUNC_MOD_EXPR:
   15538              :     case CEIL_MOD_EXPR:
   15539              :     case FLOOR_MOD_EXPR:
   15540              :     case ROUND_MOD_EXPR:
   15541              :     case RDIV_EXPR:
   15542              :     case EXACT_DIV_EXPR:
   15543              :     case MIN_EXPR:
   15544              :     case MAX_EXPR:
   15545              :     case BIT_IOR_EXPR:
   15546              :     case BIT_XOR_EXPR:
   15547              :     case BIT_AND_EXPR:
   15548              : 
   15549              :     case LSHIFT_EXPR:
   15550              :     case RSHIFT_EXPR:
   15551              :     case LROTATE_EXPR:
   15552              :     case RROTATE_EXPR:
   15553              :       return true;
   15554              : 
   15555            0 :     default:
   15556            0 :       return false;
   15557              :     }
   15558              : }
   15559              : 
   15560              : /* Return a typenode for the "standard" C type with a given name.  */
   15561              : tree
   15562       949827 : get_typenode_from_name (const char *name)
   15563              : {
   15564       949827 :   if (name == NULL || *name == '\0')
   15565              :     return NULL_TREE;
   15566              : 
   15567       949827 :   if (strcmp (name, "char") == 0)
   15568            0 :     return char_type_node;
   15569       949827 :   if (strcmp (name, "unsigned char") == 0)
   15570        98070 :     return unsigned_char_type_node;
   15571       851757 :   if (strcmp (name, "signed char") == 0)
   15572        98070 :     return signed_char_type_node;
   15573              : 
   15574       753687 :   if (strcmp (name, "short int") == 0)
   15575        66897 :     return short_integer_type_node;
   15576       686790 :   if (strcmp (name, "short unsigned int") == 0)
   15577        65380 :     return short_unsigned_type_node;
   15578              : 
   15579       621410 :   if (strcmp (name, "int") == 0)
   15580        67725 :     return integer_type_node;
   15581       553685 :   if (strcmp (name, "unsigned int") == 0)
   15582        66198 :     return unsigned_type_node;
   15583              : 
   15584       487487 :   if (strcmp (name, "long int") == 0)
   15585       290529 :     return long_integer_type_node;
   15586       196958 :   if (strcmp (name, "long unsigned int") == 0)
   15587       193686 :     return long_unsigned_type_node;
   15588              : 
   15589         3272 :   if (strcmp (name, "long long int") == 0)
   15590         1636 :     return long_long_integer_type_node;
   15591         1636 :   if (strcmp (name, "long long unsigned int") == 0)
   15592         1636 :     return long_long_unsigned_type_node;
   15593              : 
   15594            0 :   gcc_unreachable ();
   15595              : }
   15596              : 
   15597              : /* List of pointer types used to declare builtins before we have seen their
   15598              :    real declaration.
   15599              : 
   15600              :    Keep the size up to date in tree.h !  */
   15601              : const builtin_structptr_type builtin_structptr_types[6] =
   15602              : {
   15603              :   { fileptr_type_node, ptr_type_node, "FILE" },
   15604              :   { const_tm_ptr_type_node, const_ptr_type_node, "tm" },
   15605              :   { fenv_t_ptr_type_node, ptr_type_node, "fenv_t" },
   15606              :   { const_fenv_t_ptr_type_node, const_ptr_type_node, "fenv_t" },
   15607              :   { fexcept_t_ptr_type_node, ptr_type_node, "fexcept_t" },
   15608              :   { const_fexcept_t_ptr_type_node, const_ptr_type_node, "fexcept_t" }
   15609              : };
   15610              : 
   15611              : /* Return the maximum object size.  */
   15612              : 
   15613              : tree
   15614      7599528 : max_object_size (void)
   15615              : {
   15616              :   /* To do: Make this a configurable parameter.  */
   15617      7599528 :   return TYPE_MAX_VALUE (ptrdiff_type_node);
   15618              : }
   15619              : 
   15620              : /* A wrapper around TARGET_VERIFY_TYPE_CONTEXT that makes the silent_p
   15621              :    parameter default to false and that weeds out error_mark_node.  */
   15622              : 
   15623              : bool
   15624    155503982 : verify_type_context (location_t loc, type_context_kind context,
   15625              :                      const_tree type, bool silent_p)
   15626              : {
   15627    155503982 :   if (type == error_mark_node)
   15628              :     return true;
   15629              : 
   15630    155503886 :   gcc_assert (TYPE_P (type));
   15631    155503886 :   return (!targetm.verify_type_context
   15632    155503886 :           || targetm.verify_type_context (loc, context, type, silent_p));
   15633              : }
   15634              : 
   15635              : /* Callback of walk_tree telling whether the current tree pointed by TP is the
   15636              :    one provided as DATA.  */
   15637              : 
   15638              : static tree
   15639         4739 : find_tree_1 (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED, void *data)
   15640              : {
   15641         4739 :   if (*tp == data)
   15642              :     return (tree) data;
   15643              :   else
   15644         4667 :     return NULL;
   15645              : }
   15646              : 
   15647              : /* Return whether SEARCH is a subtree of TOP.  */
   15648              : 
   15649              : bool
   15650         4067 : find_tree (tree top, tree search)
   15651              : {
   15652         4067 :   return walk_tree_without_duplicates (&top, find_tree_1, search) != 0;
   15653              : }
   15654              : 
   15655              : /* Return true if NEW_ASM and DELETE_ASM name a valid pair of new and
   15656              :    delete operators.  Return false if they may or may not name such
   15657              :    a pair and, when nonnull, set *PCERTAIN to true if they certainly
   15658              :    do not.  */
   15659              : 
   15660              : bool
   15661        69254 : valid_new_delete_pair_p (tree new_asm, tree delete_asm,
   15662              :                          bool *pcertain /* = NULL */)
   15663              : {
   15664        69254 :   bool certain;
   15665        69254 :   if (!pcertain)
   15666        56347 :     pcertain = &certain;
   15667              : 
   15668        69254 :   const char *new_name = IDENTIFIER_POINTER (new_asm);
   15669        69254 :   const char *delete_name = IDENTIFIER_POINTER (delete_asm);
   15670        69254 :   unsigned int new_len = IDENTIFIER_LENGTH (new_asm);
   15671        69254 :   unsigned int delete_len = IDENTIFIER_LENGTH (delete_asm);
   15672              : 
   15673              :   /* The following failures are due to invalid names so they're not
   15674              :      considered certain mismatches.  */
   15675        69254 :   *pcertain = false;
   15676              : 
   15677        69254 :   if (new_len < 5 || delete_len < 6)
   15678              :     return false;
   15679        69254 :   if (new_name[0] == '_')
   15680        69182 :     ++new_name, --new_len;
   15681        69254 :   if (new_name[0] == '_')
   15682            0 :     ++new_name, --new_len;
   15683        69254 :   if (delete_name[0] == '_')
   15684        69254 :     ++delete_name, --delete_len;
   15685        69254 :   if (delete_name[0] == '_')
   15686            0 :     ++delete_name, --delete_len;
   15687        69254 :   if (new_len < 4 || delete_len < 5)
   15688              :     return false;
   15689              : 
   15690              :   /* The following failures are due to names of user-defined operators
   15691              :      so they're also not considered certain mismatches.  */
   15692              : 
   15693              :   /* *_len is now just the length after initial underscores.  */
   15694        69254 :   if (new_name[0] != 'Z' || new_name[1] != 'n')
   15695              :     return false;
   15696        68569 :   if (delete_name[0] != 'Z' || delete_name[1] != 'd')
   15697              :     return false;
   15698              : 
   15699              :   /* The following failures are certain mismatches.  */
   15700        68493 :   *pcertain = true;
   15701              : 
   15702              :   /* _Znw must match _Zdl, _Zna must match _Zda.  */
   15703        68493 :   if ((new_name[2] != 'w' || delete_name[2] != 'l')
   15704         5202 :       && (new_name[2] != 'a' || delete_name[2] != 'a'))
   15705              :     return false;
   15706        68376 :   if (new_name[3] == 'I' || delete_name[3] == 'I')
   15707              :     {
   15708              :       /* When ::operator new or ::operator delete are function templates,
   15709              :          return uncertain mismatch, we need demangler in that case.  */
   15710           24 :       *pcertain = false;
   15711           24 :       return false;
   15712              :     }
   15713              :   /* 'j', 'm' and 'y' correspond to size_t.  */
   15714        68352 :   if (new_name[3] != 'j' && new_name[3] != 'm' && new_name[3] != 'y')
   15715              :     return false;
   15716        68352 :   if (delete_name[3] != 'P' || delete_name[4] != 'v')
   15717              :     return false;
   15718        68352 :   if (new_len == 4
   15719          566 :       || (new_len == 18 && !memcmp (new_name + 4, "RKSt9nothrow_t", 14)))
   15720              :     {
   15721              :       /* _ZnXY or _ZnXYRKSt9nothrow_t matches
   15722              :          _ZdXPv, _ZdXPvY and _ZdXPvRKSt9nothrow_t.  */
   15723        68041 :       if (delete_len == 5)
   15724              :         return true;
   15725        61304 :       if (delete_len == 6 && delete_name[5] == new_name[3])
   15726              :         return true;
   15727           42 :       if (delete_len == 19 && !memcmp (delete_name + 5, "RKSt9nothrow_t", 14))
   15728              :         return true;
   15729              :     }
   15730          311 :   else if ((new_len == 19 && !memcmp (new_name + 4, "St11align_val_t", 15))
   15731           54 :            || (new_len == 33
   15732           10 :                && !memcmp (new_name + 4, "St11align_val_tRKSt9nothrow_t", 29)))
   15733              :     {
   15734              :       /* _ZnXYSt11align_val_t or _ZnXYSt11align_val_tRKSt9nothrow_t matches
   15735              :          _ZdXPvSt11align_val_t or _ZdXPvYSt11align_val_t or
   15736              :          _ZdXPvSt11align_val_tRKSt9nothrow_t.  */
   15737          267 :       if (delete_len == 20 && !memcmp (delete_name + 5, "St11align_val_t", 15))
   15738              :         return true;
   15739          144 :       if (delete_len == 21
   15740          129 :           && delete_name[5] == new_name[3]
   15741          129 :           && !memcmp (delete_name + 6, "St11align_val_t", 15))
   15742              :         return true;
   15743           15 :       if (delete_len == 34
   15744            9 :           && !memcmp (delete_name + 5, "St11align_val_tRKSt9nothrow_t", 29))
   15745              :         return true;
   15746              :     }
   15747              : 
   15748              :   /* The negative result is conservative.  */
   15749           50 :   *pcertain = false;
   15750           50 :   return false;
   15751              : }
   15752              : 
   15753              : /* Return the zero-based number corresponding to the argument being
   15754              :    deallocated if FNDECL is a deallocation function or an out-of-bounds
   15755              :    value if it isn't.  */
   15756              : 
   15757              : unsigned
   15758     23496693 : fndecl_dealloc_argno (tree fndecl)
   15759              : {
   15760              :   /* A call to operator delete isn't recognized as one to a built-in.  */
   15761     23496693 :   if (DECL_IS_OPERATOR_DELETE_P (fndecl))
   15762              :     {
   15763       340494 :       if (DECL_IS_REPLACEABLE_OPERATOR (fndecl))
   15764              :         return 0;
   15765              : 
   15766              :       /* Avoid placement delete that's not been inlined.  */
   15767        26599 :       tree fname = DECL_ASSEMBLER_NAME (fndecl);
   15768        26599 :       if (id_equal (fname, "_ZdlPvS_")       // ordinary form
   15769        26599 :           || id_equal (fname, "_ZdaPvS_"))   // array form
   15770        23845 :         return UINT_MAX;
   15771              :       return 0;
   15772              :     }
   15773              : 
   15774              :   /* TODO: Handle user-defined functions with attribute malloc?  Handle
   15775              :      known non-built-ins like fopen?  */
   15776     23156199 :   if (fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
   15777              :     {
   15778      5691517 :       switch (DECL_FUNCTION_CODE (fndecl))
   15779              :         {
   15780              :         case BUILT_IN_FREE:
   15781              :         case BUILT_IN_REALLOC:
   15782              :         case BUILT_IN_GOMP_FREE:
   15783              :         case BUILT_IN_GOMP_REALLOC:
   15784              :           return 0;
   15785      5455746 :         default:
   15786      5455746 :           break;
   15787              :         }
   15788      5455746 :       return UINT_MAX;
   15789              :     }
   15790              : 
   15791     17464682 :   tree attrs = DECL_ATTRIBUTES (fndecl);
   15792     17464682 :   if (!attrs)
   15793              :     return UINT_MAX;
   15794              : 
   15795            0 :   for (tree atfree = attrs;
   15796      4023954 :        (atfree = lookup_attribute ("*dealloc", atfree));
   15797            0 :        atfree = TREE_CHAIN (atfree))
   15798              :     {
   15799         4942 :       tree alloc = TREE_VALUE (atfree);
   15800         4942 :       if (!alloc)
   15801            0 :         continue;
   15802              : 
   15803         4942 :       tree pos = TREE_CHAIN (alloc);
   15804         4942 :       if (!pos)
   15805              :         return 0;
   15806              : 
   15807         2752 :       pos = TREE_VALUE (pos);
   15808         2752 :       return TREE_INT_CST_LOW (pos) - 1;
   15809              :     }
   15810              : 
   15811              :   return UINT_MAX;
   15812              : }
   15813              : 
   15814              : /* If EXPR refers to a character array or pointer declared attribute
   15815              :    nonstring, return a decl for that array or pointer and set *REF
   15816              :    to the referenced enclosing object or pointer.  Otherwise return
   15817              :    null.  */
   15818              : 
   15819              : tree
   15820      1400973 : get_attr_nonstring_decl (tree expr, tree *ref)
   15821              : {
   15822      1406681 :   tree decl = expr;
   15823      1406681 :   tree var = NULL_TREE;
   15824      1406681 :   if (TREE_CODE (decl) == SSA_NAME)
   15825              :     {
   15826       834523 :       gimple *def = SSA_NAME_DEF_STMT (decl);
   15827              : 
   15828       834523 :       if (is_gimple_assign (def))
   15829              :         {
   15830        44161 :           tree_code code = gimple_assign_rhs_code (def);
   15831        44161 :           if (code == ADDR_EXPR
   15832        44161 :               || code == COMPONENT_REF
   15833        29291 :               || code == VAR_DECL)
   15834        19343 :             decl = gimple_assign_rhs1 (def);
   15835              :         }
   15836              :       else
   15837       790362 :         var = SSA_NAME_VAR (decl);
   15838              :     }
   15839              : 
   15840      1406681 :   if (TREE_CODE (decl) == ADDR_EXPR)
   15841        25954 :     decl = TREE_OPERAND (decl, 0);
   15842              : 
   15843              :   /* To simplify calling code, store the referenced DECL regardless of
   15844              :      the attribute determined below, but avoid storing the SSA_NAME_VAR
   15845              :      obtained above (it's not useful for dataflow purposes).  */
   15846      1406681 :   if (ref)
   15847         5463 :     *ref = decl;
   15848              : 
   15849              :   /* Use the SSA_NAME_VAR that was determined above to see if it's
   15850              :      declared nonstring.  Otherwise drill down into the referenced
   15851              :      DECL.  */
   15852      1406681 :   if (var)
   15853              :     decl = var;
   15854              :   else
   15855              :     {
   15856       641175 :       while (TREE_CODE (decl) == ARRAY_REF)
   15857        18669 :         decl = TREE_OPERAND (decl, 0);
   15858       622506 :       if (TREE_CODE (decl) == COMPONENT_REF)
   15859        16643 :         decl = TREE_OPERAND (decl, 1);
   15860       605863 :       else if (TREE_CODE (decl) == MEM_REF)
   15861         5708 :         return get_attr_nonstring_decl (TREE_OPERAND (decl, 0), ref);
   15862              :     }
   15863              : 
   15864      1400973 :   if (DECL_P (decl) && lookup_attribute ("nonstring", DECL_ATTRIBUTES (decl)))
   15865         7921 :     return decl;
   15866              : 
   15867              :   return NULL_TREE;
   15868              : }
   15869              : 
   15870              : /* Returns an auto_vec of string_slices containing the version strings from
   15871              :    ARGLIST.  DEFAULT_COUNT is incremented for each default version found.
   15872              :    If FILTER is true then any invalid versions strings are not included.  */
   15873              : 
   15874              : auto_vec<string_slice>
   15875          214 : get_clone_attr_versions (const tree arglist,
   15876              :                          int *default_count,
   15877              :                          bool filter)
   15878              : {
   15879          214 :   gcc_assert (TREE_CODE (arglist) == TREE_LIST);
   15880          214 :   auto_vec<string_slice> versions;
   15881              : 
   15882          214 :   static const char separator_str[] = {TARGET_CLONES_ATTR_SEPARATOR, 0};
   15883          214 :   string_slice separators = string_slice (separator_str);
   15884              : 
   15885          782 :   for (tree arg = arglist; arg; arg = TREE_CHAIN (arg))
   15886              :     {
   15887          568 :       string_slice str = string_slice (TREE_STRING_POINTER (TREE_VALUE (arg)));
   15888         1732 :       while (str.is_valid ())
   15889              :         {
   15890          596 :           string_slice attr = string_slice::tokenize (&str, separators);
   15891          596 :           attr = attr.strip ();
   15892              : 
   15893          596 :           if (filter && !targetm.check_target_clone_version (attr, NULL))
   15894            0 :             continue;
   15895              : 
   15896          596 :           if (attr == "default" && default_count)
   15897          212 :             (*default_count)++;
   15898          596 :           versions.safe_push (attr);
   15899              :         }
   15900              :     }
   15901          214 :   return versions;
   15902              : }
   15903              : 
   15904              : /* Returns an auto_vec of string_slices containing the version strings from
   15905              :    the target_clone attribute from DECL.  DEFAULT_COUNT is incremented for each
   15906              :    default version found.  If FILTER is true then any invalid versions strings
   15907              :    are not included.  */
   15908              : auto_vec<string_slice>
   15909          100 : get_clone_versions (const tree decl, int *default_count, bool filter)
   15910              : {
   15911          100 :   tree attr = lookup_attribute ("target_clones", DECL_ATTRIBUTES (decl));
   15912          100 :   if (!attr)
   15913            0 :     return auto_vec<string_slice> ();
   15914          100 :   tree arglist = TREE_VALUE (attr);
   15915          100 :   return get_clone_attr_versions (arglist, default_count, filter);
   15916              : }
   15917              : 
   15918              : /* If DECL has a target_version attribute, returns a string_slice containing the
   15919              :    attribute value.  Otherwise, returns string_slice::invalid.
   15920              :    Only works for target_version due to target attributes allowing multiple
   15921              :    string arguments to specify one target.  */
   15922              : string_slice
   15923            0 : get_target_version (const tree decl)
   15924              : {
   15925            0 :   gcc_assert (!TARGET_HAS_FMV_TARGET_ATTRIBUTE);
   15926              : 
   15927              :   tree attr = lookup_attribute ("target_version", DECL_ATTRIBUTES (decl));
   15928              : 
   15929              :   if (!attr)
   15930              :     return string_slice::invalid ();
   15931              : 
   15932              :   return string_slice (TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))))
   15933              :            .strip ();
   15934              : }
   15935              : 
   15936              : /* Returns true if FN1 and FN2 define disjoint function versions in an FMV
   15937              :    function set.  That is, the two declarations are completely non-overlapping.
   15938              :    For target_version semantics, that means if one is a target clone and one is
   15939              :    a target version, the target_version must not be defined by the target_clone,
   15940              :    and for two target_clones, they must not define any of the same version.
   15941              : 
   15942              :    FN1 and FN2 should be function decls.  */
   15943              : 
   15944              : bool
   15945     30844927 : disjoint_version_decls (tree fn1, tree fn2)
   15946              : {
   15947     30844927 :   if (TREE_CODE (fn1) != FUNCTION_DECL
   15948     30843907 :       || TREE_CODE (fn2) != FUNCTION_DECL)
   15949              :     return false;
   15950              : 
   15951     28533298 :   if (TARGET_HAS_FMV_TARGET_ATTRIBUTE)
   15952              :     {
   15953     28533298 :       tree attr1 = lookup_attribute ("target", DECL_ATTRIBUTES (fn1));
   15954     28533298 :       tree attr2 = lookup_attribute ("target", DECL_ATTRIBUTES (fn2));
   15955              : 
   15956              :       /* At least one function decl should have the target attribute
   15957              :          specified.  */
   15958     28533298 :       if (attr1 == NULL_TREE && attr2 == NULL_TREE)
   15959              :         return false;
   15960              : 
   15961              :       /* Diagnose missing target attribute if one of the decls is already
   15962              :          multi-versioned.  */
   15963        18867 :       if (attr1 == NULL_TREE || attr2 == NULL_TREE)
   15964              :         {
   15965          363 :           if (DECL_FUNCTION_VERSIONED (fn1) || DECL_FUNCTION_VERSIONED (fn2))
   15966              :             {
   15967          114 :               if (attr2 != NULL_TREE)
   15968              :                 {
   15969          114 :                   std::swap (fn1, fn2);
   15970          114 :                   attr1 = attr2;
   15971              :                 }
   15972          114 :               auto_diagnostic_group d;
   15973          114 :               error_at (DECL_SOURCE_LOCATION (fn2),
   15974              :                         "missing %<target%> attribute for multi-versioned %qD",
   15975              :                         fn2);
   15976          114 :               inform (DECL_SOURCE_LOCATION (fn1),
   15977              :                       "previous declaration of %qD", fn1);
   15978              :               /* Prevent diagnosing of the same error multiple times.  */
   15979          114 :               DECL_ATTRIBUTES (fn2)
   15980          228 :                 = tree_cons (get_identifier ("target"),
   15981          114 :                              copy_node (TREE_VALUE (attr1)),
   15982          114 :                              DECL_ATTRIBUTES (fn2));
   15983          114 :             }
   15984              :           return false;
   15985              :         }
   15986              : 
   15987        18504 :       char *target1 = sorted_attr_string (TREE_VALUE (attr1));
   15988        18504 :       char *target2 = sorted_attr_string (TREE_VALUE (attr2));
   15989              : 
   15990              :       /* The sorted target strings must be different for fn1 and fn2
   15991              :          to be versions.  */
   15992        18504 :       bool result = strcmp (target1, target2) != 0;
   15993              : 
   15994        18504 :       XDELETEVEC (target1);
   15995        18504 :       XDELETEVEC (target2);
   15996              : 
   15997        18504 :       return result;
   15998              :     }
   15999              :   else
   16000              :     {
   16001              :       /* As this is symmetric, can remove the case where fn2 is target clone
   16002              :          and fn1 is target version by swapping here.  */
   16003              :       if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (fn2)))
   16004              :         std::swap (fn1, fn2);
   16005              : 
   16006              :       if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (fn1)))
   16007              :         {
   16008              :           auto_vec<string_slice> fn1_versions = get_clone_versions (fn1);
   16009              :           /* fn1 is target_clone.  */
   16010              :           if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (fn2)))
   16011              :             {
   16012              :               /* Both are target_clone.  */
   16013              :               auto_vec<string_slice> fn2_versions = get_clone_versions (fn2);
   16014              :               for (string_slice v1 : fn1_versions)
   16015              :                 {
   16016              :                   for (string_slice v2 : fn2_versions)
   16017              :                     if (targetm.target_option.same_function_versions
   16018              :                           (v1, NULL_TREE, v2, NULL_TREE))
   16019              :                       return false;
   16020              :                 }
   16021              :               return true;
   16022              :             }
   16023              :           else
   16024              :             {
   16025              :               string_slice v2 = get_target_version (fn2);
   16026              : 
   16027              :               /* target and target_clones is always conflicting for target
   16028              :                  semantics.  */
   16029              :               if (TARGET_HAS_FMV_TARGET_ATTRIBUTE)
   16030              :                 return false;
   16031              : 
   16032              :               /* Only fn1 is target clone.  */
   16033              :               if (!v2.is_valid ())
   16034              :                 v2 = "default";
   16035              :               for (string_slice v1 : fn1_versions)
   16036              :                 if (targetm.target_option.same_function_versions
   16037              :                       (v1, NULL_TREE, v2, NULL_TREE))
   16038              :                   return false;
   16039              :               return true;
   16040              :             }
   16041              :         }
   16042              :       else
   16043              :         {
   16044              :           /* Both are target_version.  */
   16045              :           string_slice v1 = get_target_version (fn1);
   16046              :           string_slice v2 = get_target_version (fn2);
   16047              : 
   16048              :           if (!v1.is_valid () && !v2.is_valid ())
   16049              :             return false;
   16050              : 
   16051              :           if (!v1.is_valid ())
   16052              :             v1 = "default";
   16053              :           if (!v2.is_valid ())
   16054              :             v2 = "default";
   16055              : 
   16056              :           if (targetm.target_option.same_function_versions (v1, NULL_TREE,
   16057              :                                                             v2, NULL_TREE))
   16058              :             return false;
   16059              : 
   16060              :           return true;
   16061              :         }
   16062              :     }
   16063              : }
   16064              : 
   16065              : /* Check if the target_version/target_clones attributes are mergeable
   16066              :    for two decls, and if so returns false.
   16067              :    If they aren't mergeable, diagnose this and return true.
   16068              :    Only works for target_version semantics.  */
   16069              : bool
   16070            0 : diagnose_versioned_decls (tree old_decl, tree new_decl)
   16071              : {
   16072            0 :   gcc_assert (!TARGET_HAS_FMV_TARGET_ATTRIBUTE);
   16073              : 
   16074              :   string_slice old_target_attr = get_target_version (old_decl);
   16075              :   string_slice new_target_attr = get_target_version (new_decl);
   16076              : 
   16077              :   tree old_target_clones_attr = lookup_attribute ("target_clones",
   16078              :                                                   DECL_ATTRIBUTES (old_decl));
   16079              :   tree new_target_clones_attr = lookup_attribute ("target_clones",
   16080              :                                                   DECL_ATTRIBUTES (new_decl));
   16081              : 
   16082              :   /* If none of these are annotated, then it is mergeable.  */
   16083              :   if (!old_target_attr.is_valid ()
   16084              :       && !old_target_attr.is_valid ()
   16085              :       && !old_target_clones_attr
   16086              :       && !new_target_clones_attr)
   16087              :     return false;
   16088              : 
   16089              :   /* If fn1 is unnanotated and fn2 contains default, then is mergeable.  */
   16090              :   if (!old_target_attr.is_valid ()
   16091              :       && !old_target_clones_attr
   16092              :       && is_function_default_version (new_decl))
   16093              :     return false;
   16094              : 
   16095              :   /* If fn2 is unnanotated and fn1 contains default, then is mergeable.  */
   16096              :   if (!new_target_attr.is_valid ()
   16097              :       && !new_target_clones_attr
   16098              :       && is_function_default_version (old_decl))
   16099              :     return false;
   16100              : 
   16101              :   /* In the case where both are annotated with target_clones, only mergeable if
   16102              :      the two sets of target_clones imply the same set of versions.  */
   16103              :   if (old_target_clones_attr && new_target_clones_attr)
   16104              :     {
   16105              :       auto_vec<string_slice> old_versions = get_clone_versions (old_decl);
   16106              :       auto_vec<string_slice> new_versions = get_clone_versions (new_decl);
   16107              : 
   16108              :       bool mergeable = true;
   16109              : 
   16110              :       if (old_versions.length () != new_versions.length ())
   16111              :         mergeable = false;
   16112              : 
   16113              :       /* Check both inclusion directions.  */
   16114              :       for (auto oldv: old_versions)
   16115              :         {
   16116              :           bool matched = false;
   16117              :           for (auto newv: new_versions)
   16118              :             if (targetm.target_option.same_function_versions (oldv, old_decl,
   16119              :                                                               newv, new_decl))
   16120              :               matched = true;
   16121              :           if (!matched)
   16122              :             mergeable = false;
   16123              :         }
   16124              : 
   16125              :       for (auto newv: new_versions)
   16126              :         {
   16127              :           bool matched = false;
   16128              :           for (auto oldv: old_versions)
   16129              :             if (targetm.target_option.same_function_versions (oldv, old_decl,
   16130              :                                                               newv, new_decl))
   16131              :               matched = true;
   16132              :           if (!matched)
   16133              :             mergeable = false;
   16134              :         }
   16135              : 
   16136              :       if (!mergeable)
   16137              :         {
   16138              :           error_at (DECL_SOURCE_LOCATION (new_decl),
   16139              :                     "%qD conflicts with overlapping %<target_clone%> "
   16140              :                     "declaration",
   16141              :                     new_decl);
   16142              :           inform (DECL_SOURCE_LOCATION (old_decl),
   16143              :                   "previous declaration of %qD", old_decl);
   16144              :           return true;
   16145              :         }
   16146              : 
   16147              :       return false;
   16148              :     }
   16149              : 
   16150              :   /* If olddecl is target clones and newdecl is a target_version.
   16151              :      As they are not distinct this implies newdecl redefines a version of
   16152              :      olddecl.  Not mergeable.  */
   16153              :   if (new_target_clones_attr)
   16154              :     {
   16155              :       gcc_assert (old_target_attr.is_valid ());
   16156              : 
   16157              :       error_at (DECL_SOURCE_LOCATION (new_decl),
   16158              :                 "%qD conflicts for version %qB",
   16159              :                 new_decl, &old_target_attr);
   16160              :       inform (DECL_SOURCE_LOCATION (old_decl),
   16161              :               "previous declaration of %qD",
   16162              :               old_decl);
   16163              :       return true;
   16164              :     }
   16165              : 
   16166              :   if (old_target_clones_attr)
   16167              :     {
   16168              :       gcc_assert (new_target_attr.is_valid ());
   16169              : 
   16170              :       error_at (DECL_SOURCE_LOCATION (new_decl),
   16171              :                 "%qD conflicts with a previous declaration for version %qB",
   16172              :                 new_decl, &new_target_attr);
   16173              :       inform (DECL_SOURCE_LOCATION (old_decl),
   16174              :               "previous declaration of %qD",
   16175              :               old_decl);
   16176              :       return true;
   16177              :     }
   16178              : 
   16179              :   /* The only remaining case is two target_version annotated decls.  */
   16180              :   return !targetm.target_option.same_function_versions
   16181              :             (old_target_attr, old_decl, new_target_attr, new_decl);
   16182              : }
   16183              : 
   16184              : 
   16185              : /* This page contains routines to unshare tree nodes, i.e. to duplicate tree
   16186              :    nodes that are referenced more than once in GENERIC functions.  This is
   16187              :    necessary because gimplification (translation into GIMPLE) is performed
   16188              :    by modifying tree nodes in-place, so gimplification of a shared node in a
   16189              :    first context could generate an invalid GIMPLE form in a second context.
   16190              : 
   16191              :    This is achieved with a simple mark/copy/unmark algorithm that walks the
   16192              :    GENERIC representation top-down, marks nodes with TREE_VISITED the first
   16193              :    time it encounters them, duplicates them if they already have TREE_VISITED
   16194              :    set, and finally removes the TREE_VISITED marks it has set.
   16195              : 
   16196              :    The algorithm works only at the function level, i.e. it generates a GENERIC
   16197              :    representation of a function with no nodes shared within the function when
   16198              :    passed a GENERIC function (except for nodes that are allowed to be shared).
   16199              : 
   16200              :    At the global level, it is also necessary to unshare tree nodes that are
   16201              :    referenced in more than one function, for the same aforementioned reason.
   16202              :    This requires some cooperation from the front-end.  There are 2 strategies:
   16203              : 
   16204              :      1. Manual unsharing.  The front-end needs to call unshare_expr on every
   16205              :         expression that might end up being shared across functions.
   16206              : 
   16207              :      2. Deep unsharing.  This is an extension of regular unsharing.  Instead
   16208              :         of calling unshare_expr on expressions that might be shared across
   16209              :         functions, the front-end pre-marks them with TREE_VISITED.  This will
   16210              :         ensure that they are unshared on the first reference within functions
   16211              :         when the regular unsharing algorithm runs.  The counterpart is that
   16212              :         this algorithm must look deeper than for manual unsharing, which is
   16213              :         specified by LANG_HOOKS_DEEP_UNSHARING.
   16214              : 
   16215              :   If there are only few specific cases of node sharing across functions, it is
   16216              :   probably easier for a front-end to unshare the expressions manually.  On the
   16217              :   contrary, if the expressions generated at the global level are as widespread
   16218              :   as expressions generated within functions, deep unsharing is very likely the
   16219              :   way to go.  */
   16220              : 
   16221              : /* Similar to copy_tree_r but do not copy SAVE_EXPR or TARGET_EXPR nodes.
   16222              :    These nodes model computations that must be done once.  If we were to
   16223              :    unshare something like SAVE_EXPR(i++), the gimplification process would
   16224              :    create wrong code.  However, if DATA is non-null, it must hold a pointer
   16225              :    set that is used to unshare the subtrees of these nodes.  */
   16226              : 
   16227              : static tree
   16228   2818645947 : mostly_copy_tree_r (tree *tp, int *walk_subtrees, void *data)
   16229              : {
   16230   2818645947 :   tree t = *tp;
   16231   2818645947 :   enum tree_code code = TREE_CODE (t);
   16232              : 
   16233              :   /* Do not copy SAVE_EXPR, TARGET_EXPR or BIND_EXPR nodes themselves, but
   16234              :      copy their subtrees if we can make sure to do it only once.  */
   16235   2818645947 :   if (code == SAVE_EXPR || code == TARGET_EXPR || code == BIND_EXPR)
   16236              :     {
   16237     11628900 :       if (data && !((hash_set<tree> *)data)->add (t))
   16238              :         ;
   16239              :       else
   16240     11628900 :         *walk_subtrees = 0;
   16241              :     }
   16242              : 
   16243              :   /* Stop at types, decls, constants like copy_tree_r.  */
   16244   2807017047 :   else if (TREE_CODE_CLASS (code) == tcc_type
   16245              :            || TREE_CODE_CLASS (code) == tcc_declaration
   16246   2807017047 :            || TREE_CODE_CLASS (code) == tcc_constant)
   16247   1736216220 :     *walk_subtrees = 0;
   16248              : 
   16249              :   /* Cope with the statement expression extension.  */
   16250   1070800827 :   else if (code == STATEMENT_LIST)
   16251              :     ;
   16252              : 
   16253              :   /* Leave the bulk of the work to copy_tree_r itself.  */
   16254              :   else
   16255   1070751183 :     copy_tree_r (tp, walk_subtrees, NULL);
   16256              : 
   16257   2818645947 :   return NULL_TREE;
   16258              : }
   16259              : 
   16260              : /* Callback for walk_tree to unshare most of the shared trees rooted at *TP.
   16261              :    If *TP has been visited already, then *TP is deeply copied by calling
   16262              :    mostly_copy_tree_r.  DATA is passed to mostly_copy_tree_r unmodified.  */
   16263              : 
   16264              : static tree
   16265    288873938 : copy_if_shared_r (tree *tp, int *walk_subtrees, void *data)
   16266              : {
   16267    288873938 :   tree t = *tp;
   16268    288873938 :   enum tree_code code = TREE_CODE (t);
   16269              : 
   16270              :   /* Skip types, decls, and constants.  But we do want to look at their
   16271              :      types and the bounds of types.  Mark them as visited so we properly
   16272              :      unmark their subtrees on the unmark pass.  If we've already seen them,
   16273              :      don't look down further.  */
   16274    288873938 :   if (TREE_CODE_CLASS (code) == tcc_type
   16275              :       || TREE_CODE_CLASS (code) == tcc_declaration
   16276    288873938 :       || TREE_CODE_CLASS (code) == tcc_constant)
   16277              :     {
   16278    137394743 :       if (TREE_VISITED (t))
   16279     84241918 :         *walk_subtrees = 0;
   16280              :       else
   16281     53152825 :         TREE_VISITED (t) = 1;
   16282              :     }
   16283              : 
   16284              :   /* If this node has been visited already, unshare it and don't look
   16285              :      any deeper.  */
   16286    151479195 :   else if (TREE_VISITED (t))
   16287              :     {
   16288      1812566 :       walk_tree (tp, mostly_copy_tree_r, data, NULL);
   16289      1812566 :       *walk_subtrees = 0;
   16290              :     }
   16291              : 
   16292              :   /* Otherwise, mark the node as visited and keep looking.  */
   16293              :   else
   16294    149666629 :     TREE_VISITED (t) = 1;
   16295              : 
   16296    288873938 :   return NULL_TREE;
   16297              : }
   16298              : 
   16299              : /* Unshare most of the shared trees rooted at *TP.  DATA is passed to the
   16300              :    copy_if_shared_r callback unmodified.  */
   16301              : 
   16302              : void
   16303      9114036 : copy_if_shared (tree *tp, void *data)
   16304              : {
   16305      9114036 :   walk_tree (tp, copy_if_shared_r, data, NULL);
   16306      9114036 : }
   16307              : 
   16308              : /* Unconditionally make an unshared copy of EXPR.  This is used when using
   16309              :    stored expressions which span multiple functions, such as BINFO_VTABLE,
   16310              :    as the normal unsharing process can't tell that they're shared.  */
   16311              : 
   16312              : tree
   16313   1573998746 : unshare_expr (tree expr)
   16314              : {
   16315   1573998746 :   walk_tree (&expr, mostly_copy_tree_r, NULL, NULL);
   16316   1573998746 :   return expr;
   16317              : }
   16318              : 
   16319              : /* Worker for unshare_expr_without_location.  */
   16320              : 
   16321              : static tree
   16322     12898860 : prune_expr_location (tree *tp, int *walk_subtrees, void *)
   16323              : {
   16324     12898860 :   if (EXPR_P (*tp))
   16325      6441664 :     SET_EXPR_LOCATION (*tp, UNKNOWN_LOCATION);
   16326              :   else
   16327      6457196 :     *walk_subtrees = 0;
   16328     12898860 :   return NULL_TREE;
   16329              : }
   16330              : 
   16331              : /* Similar to unshare_expr but also prune all expression locations
   16332              :    from EXPR.  */
   16333              : 
   16334              : tree
   16335     23539260 : unshare_expr_without_location (tree expr)
   16336              : {
   16337     23539260 :   walk_tree (&expr, mostly_copy_tree_r, NULL, NULL);
   16338     23539260 :   if (EXPR_P (expr))
   16339      4238132 :     walk_tree (&expr, prune_expr_location, NULL, NULL);
   16340     23539260 :   return expr;
   16341              : }
   16342              : 
   16343              : void
   16344       266934 : tree_cc_finalize (void)
   16345              : {
   16346       266934 :   clear_nonstandard_integer_type_cache ();
   16347       266934 :   vec_free (bitint_type_cache);
   16348       266934 : }
   16349              : 
   16350              : void
   16351          233 : gt_ggc_mx (tree_raw_data *x)
   16352              : {
   16353          233 :   gt_ggc_m_9tree_node (x->typed.type);
   16354          233 :   gt_ggc_m_9tree_node (x->owner);
   16355          233 : }
   16356              : 
   16357              : void
   16358           12 : gt_pch_nx (tree_raw_data *x)
   16359              : {
   16360           12 :   gt_pch_n_9tree_node (x->typed.type);
   16361           12 :   gt_pch_n_9tree_node (x->owner);
   16362           12 : }
   16363              : 
   16364              : /* For PCH we guarantee that RAW_DATA_CST's RAW_DATA_OWNER is a STRING_CST and
   16365              :    RAW_DATA_POINTER points into it.  We don't want to save/restore
   16366              :    RAW_DATA_POINTER on its own but want to restore it pointing at the same
   16367              :    offset of the STRING_CST as before.  */
   16368              : 
   16369              : void
   16370           12 : gt_pch_nx (tree_raw_data *x, gt_pointer_operator op, void *cookie)
   16371              : {
   16372           12 :   op (&x->typed.type, NULL, cookie);
   16373           12 :   gcc_checking_assert (x->owner
   16374              :                        && TREE_CODE (x->owner) == STRING_CST
   16375              :                        && x->str >= TREE_STRING_POINTER (x->owner)
   16376              :                        && (x->str + x->length
   16377              :                            <= (TREE_STRING_POINTER (x->owner)
   16378              :                                + TREE_STRING_LENGTH (x->owner))));
   16379           12 :   ptrdiff_t off = x->str - (const char *) (x->owner);
   16380           12 :   tree owner = x->owner;
   16381           12 :   op (&x->owner, NULL, cookie);
   16382           12 :   x->owner = owner;
   16383              :   /* The above op call relocates x->owner and remembers the address
   16384              :      for relocation e.g. if the compiler is position independent.
   16385              :      We then restore x->owner back to its previous value and call
   16386              :      op again, for x->owner itself this just repeats (uselessly) what
   16387              :      the first call did, but as the second argument is now non-NULL
   16388              :      and different, it also arranges for &x->str to be noted for the
   16389              :      PIE relocation.  */
   16390           12 :   op (&x->owner, &x->str, cookie);
   16391           12 :   x->str = (const char *) (x->owner) + off;
   16392           12 : }
   16393              : 
   16394              : #if CHECKING_P
   16395              : 
   16396              : namespace selftest {
   16397              : 
   16398              : /* Selftests for tree.  */
   16399              : 
   16400              : /* Verify that integer constants are sane.  */
   16401              : 
   16402              : static void
   16403            4 : test_integer_constants ()
   16404              : {
   16405            4 :   ASSERT_TRUE (integer_type_node != NULL);
   16406            4 :   ASSERT_TRUE (build_int_cst (integer_type_node, 0) != NULL);
   16407              : 
   16408            4 :   tree type = integer_type_node;
   16409              : 
   16410            4 :   tree zero = build_zero_cst (type);
   16411            4 :   ASSERT_EQ (INTEGER_CST, TREE_CODE (zero));
   16412            4 :   ASSERT_EQ (type, TREE_TYPE (zero));
   16413              : 
   16414            4 :   tree one = build_int_cst (type, 1);
   16415            4 :   ASSERT_EQ (INTEGER_CST, TREE_CODE (one));
   16416            4 :   ASSERT_EQ (type, TREE_TYPE (zero));
   16417            4 : }
   16418              : 
   16419              : /* Verify identifiers.  */
   16420              : 
   16421              : static void
   16422            4 : test_identifiers ()
   16423              : {
   16424            4 :   tree identifier = get_identifier ("foo");
   16425            4 :   ASSERT_EQ (3, IDENTIFIER_LENGTH (identifier));
   16426            4 :   ASSERT_STREQ ("foo", IDENTIFIER_POINTER (identifier));
   16427            4 : }
   16428              : 
   16429              : /* Verify LABEL_DECL.  */
   16430              : 
   16431              : static void
   16432            4 : test_labels ()
   16433              : {
   16434            4 :   tree identifier = get_identifier ("err");
   16435            4 :   tree label_decl = build_decl (UNKNOWN_LOCATION, LABEL_DECL,
   16436              :                                 identifier, void_type_node);
   16437            4 :   ASSERT_EQ (-1, LABEL_DECL_UID (label_decl));
   16438            4 :   ASSERT_FALSE (FORCED_LABEL (label_decl));
   16439            4 : }
   16440              : 
   16441              : /* Return a new VECTOR_CST node whose type is TYPE and whose values
   16442              :    are given by VALS.  */
   16443              : 
   16444              : static tree
   16445           40 : build_vector (tree type, const vec<tree> &vals MEM_STAT_DECL)
   16446              : {
   16447           80 :   gcc_assert (known_eq (vals.length (), TYPE_VECTOR_SUBPARTS (type)));
   16448           40 :   tree_vector_builder builder (type, vals.length (), 1);
   16449           40 :   builder.splice (vals);
   16450           40 :   return builder.build ();
   16451           40 : }
   16452              : 
   16453              : /* Check that VECTOR_CST ACTUAL contains the elements in EXPECTED.  */
   16454              : 
   16455              : static void
   16456           40 : check_vector_cst (const vec<tree> &expected, tree actual)
   16457              : {
   16458           80 :   ASSERT_KNOWN_EQ (expected.length (),
   16459              :                    TYPE_VECTOR_SUBPARTS (TREE_TYPE (actual)));
   16460          360 :   for (unsigned int i = 0; i < expected.length (); ++i)
   16461          320 :     ASSERT_EQ (wi::to_wide (expected[i]),
   16462              :                wi::to_wide (vector_cst_elt (actual, i)));
   16463           40 : }
   16464              : 
   16465              : /* Check that VECTOR_CST ACTUAL contains NPATTERNS duplicated elements,
   16466              :    and that its elements match EXPECTED.  */
   16467              : 
   16468              : static void
   16469            8 : check_vector_cst_duplicate (const vec<tree> &expected, tree actual,
   16470              :                             unsigned int npatterns)
   16471              : {
   16472            8 :   ASSERT_EQ (npatterns, VECTOR_CST_NPATTERNS (actual));
   16473            8 :   ASSERT_EQ (1, VECTOR_CST_NELTS_PER_PATTERN (actual));
   16474            8 :   ASSERT_EQ (npatterns, vector_cst_encoded_nelts (actual));
   16475            8 :   ASSERT_TRUE (VECTOR_CST_DUPLICATE_P (actual));
   16476            8 :   ASSERT_FALSE (VECTOR_CST_STEPPED_P (actual));
   16477            8 :   check_vector_cst (expected, actual);
   16478            8 : }
   16479              : 
   16480              : /* Check that VECTOR_CST ACTUAL contains NPATTERNS foreground elements
   16481              :    and NPATTERNS background elements, and that its elements match
   16482              :    EXPECTED.  */
   16483              : 
   16484              : static void
   16485            8 : check_vector_cst_fill (const vec<tree> &expected, tree actual,
   16486              :                        unsigned int npatterns)
   16487              : {
   16488            8 :   ASSERT_EQ (npatterns, VECTOR_CST_NPATTERNS (actual));
   16489            8 :   ASSERT_EQ (2, VECTOR_CST_NELTS_PER_PATTERN (actual));
   16490            8 :   ASSERT_EQ (2 * npatterns, vector_cst_encoded_nelts (actual));
   16491            8 :   ASSERT_FALSE (VECTOR_CST_DUPLICATE_P (actual));
   16492            8 :   ASSERT_FALSE (VECTOR_CST_STEPPED_P (actual));
   16493            8 :   check_vector_cst (expected, actual);
   16494            8 : }
   16495              : 
   16496              : /* Check that VECTOR_CST ACTUAL contains NPATTERNS stepped patterns,
   16497              :    and that its elements match EXPECTED.  */
   16498              : 
   16499              : static void
   16500           24 : check_vector_cst_stepped (const vec<tree> &expected, tree actual,
   16501              :                           unsigned int npatterns)
   16502              : {
   16503           24 :   ASSERT_EQ (npatterns, VECTOR_CST_NPATTERNS (actual));
   16504           24 :   ASSERT_EQ (3, VECTOR_CST_NELTS_PER_PATTERN (actual));
   16505           24 :   ASSERT_EQ (3 * npatterns, vector_cst_encoded_nelts (actual));
   16506           24 :   ASSERT_FALSE (VECTOR_CST_DUPLICATE_P (actual));
   16507           24 :   ASSERT_TRUE (VECTOR_CST_STEPPED_P (actual));
   16508           24 :   check_vector_cst (expected, actual);
   16509           24 : }
   16510              : 
   16511              : /* Test the creation of VECTOR_CSTs.  */
   16512              : 
   16513              : static void
   16514            4 : test_vector_cst_patterns (ALONE_CXX_MEM_STAT_INFO)
   16515              : {
   16516            4 :   auto_vec<tree, 8> elements (8);
   16517            4 :   elements.quick_grow (8);
   16518            4 :   tree element_type = build_nonstandard_integer_type (16, true);
   16519            4 :   tree vector_type = build_vector_type (element_type, 8);
   16520              : 
   16521              :   /* Test a simple linear series with a base of 0 and a step of 1:
   16522              :      { 0, 1, 2, 3, 4, 5, 6, 7 }.  */
   16523           36 :   for (unsigned int i = 0; i < 8; ++i)
   16524           32 :     elements[i] = build_int_cst (element_type, i);
   16525            4 :   tree vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16526            4 :   check_vector_cst_stepped (elements, vector, 1);
   16527              : 
   16528              :   /* Try the same with the first element replaced by 100:
   16529              :      { 100, 1, 2, 3, 4, 5, 6, 7 }.  */
   16530            4 :   elements[0] = build_int_cst (element_type, 100);
   16531            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16532            4 :   check_vector_cst_stepped (elements, vector, 1);
   16533              : 
   16534              :   /* Try a series that wraps around.
   16535              :      { 100, 65531, 65532, 65533, 65534, 65535, 0, 1 }.  */
   16536           36 :   for (unsigned int i = 1; i < 8; ++i)
   16537           28 :     elements[i] = build_int_cst (element_type, (65530 + i) & 0xffff);
   16538            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16539            4 :   check_vector_cst_stepped (elements, vector, 1);
   16540              : 
   16541              :   /* Try a downward series:
   16542              :      { 100, 79, 78, 77, 76, 75, 75, 73 }.  */
   16543           36 :   for (unsigned int i = 1; i < 8; ++i)
   16544           28 :     elements[i] = build_int_cst (element_type, 80 - i);
   16545            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16546            4 :   check_vector_cst_stepped (elements, vector, 1);
   16547              : 
   16548              :   /* Try two interleaved series with different bases and steps:
   16549              :      { 100, 53, 66, 206, 62, 212, 58, 218 }.  */
   16550            4 :   elements[1] = build_int_cst (element_type, 53);
   16551           16 :   for (unsigned int i = 2; i < 8; i += 2)
   16552              :     {
   16553           12 :       elements[i] = build_int_cst (element_type, 70 - i * 2);
   16554           12 :       elements[i + 1] = build_int_cst (element_type, 200 + i * 3);
   16555              :     }
   16556            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16557            4 :   check_vector_cst_stepped (elements, vector, 2);
   16558              : 
   16559              :   /* Try a duplicated value:
   16560              :      { 100, 100, 100, 100, 100, 100, 100, 100 }.  */
   16561           36 :   for (unsigned int i = 1; i < 8; ++i)
   16562           28 :     elements[i] = elements[0];
   16563            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16564            4 :   check_vector_cst_duplicate (elements, vector, 1);
   16565              : 
   16566              :   /* Try an interleaved duplicated value:
   16567              :      { 100, 55, 100, 55, 100, 55, 100, 55 }.  */
   16568            4 :   elements[1] = build_int_cst (element_type, 55);
   16569           28 :   for (unsigned int i = 2; i < 8; ++i)
   16570           24 :     elements[i] = elements[i - 2];
   16571            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16572            4 :   check_vector_cst_duplicate (elements, vector, 2);
   16573              : 
   16574              :   /* Try a duplicated value with 2 exceptions
   16575              :      { 41, 97, 100, 55, 100, 55, 100, 55 }.  */
   16576            4 :   elements[0] = build_int_cst (element_type, 41);
   16577            4 :   elements[1] = build_int_cst (element_type, 97);
   16578            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16579            4 :   check_vector_cst_fill (elements, vector, 2);
   16580              : 
   16581              :   /* Try with and without a step
   16582              :      { 41, 97, 100, 21, 100, 35, 100, 49 }.  */
   16583           20 :   for (unsigned int i = 3; i < 8; i += 2)
   16584           12 :     elements[i] = build_int_cst (element_type, i * 7);
   16585            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16586            4 :   check_vector_cst_stepped (elements, vector, 2);
   16587              : 
   16588              :   /* Try a fully-general constant:
   16589              :      { 41, 97, 100, 21, 100, 9990, 100, 49 }.  */
   16590            4 :   elements[5] = build_int_cst (element_type, 9990);
   16591            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16592            4 :   check_vector_cst_fill (elements, vector, 4);
   16593            4 : }
   16594              : 
   16595              : /* Verify that STRIP_NOPS (NODE) is EXPECTED.
   16596              :    Helper function for test_location_wrappers, to deal with STRIP_NOPS
   16597              :    modifying its argument in-place.  */
   16598              : 
   16599              : static void
   16600           12 : check_strip_nops (tree node, tree expected)
   16601              : {
   16602           12 :   STRIP_NOPS (node);
   16603           12 :   ASSERT_EQ (expected, node);
   16604           12 : }
   16605              : 
   16606              : /* Verify location wrappers.  */
   16607              : 
   16608              : static void
   16609            4 : test_location_wrappers ()
   16610              : {
   16611            4 :   location_t loc = BUILTINS_LOCATION;
   16612              : 
   16613            4 :   ASSERT_EQ (NULL_TREE, maybe_wrap_with_location (NULL_TREE, loc));
   16614              : 
   16615              :   /* Wrapping a constant.  */
   16616            4 :   tree int_cst = build_int_cst (integer_type_node, 42);
   16617            4 :   ASSERT_FALSE (CAN_HAVE_LOCATION_P (int_cst));
   16618            4 :   ASSERT_FALSE (location_wrapper_p (int_cst));
   16619              : 
   16620            4 :   tree wrapped_int_cst = maybe_wrap_with_location (int_cst, loc);
   16621            4 :   ASSERT_TRUE (location_wrapper_p (wrapped_int_cst));
   16622            4 :   ASSERT_EQ (loc, EXPR_LOCATION (wrapped_int_cst));
   16623            4 :   ASSERT_EQ (int_cst, tree_strip_any_location_wrapper (wrapped_int_cst));
   16624              : 
   16625              :   /* We shouldn't add wrapper nodes for UNKNOWN_LOCATION.  */
   16626            4 :   ASSERT_EQ (int_cst, maybe_wrap_with_location (int_cst, UNKNOWN_LOCATION));
   16627              : 
   16628              :   /* We shouldn't add wrapper nodes for nodes that CAN_HAVE_LOCATION_P.  */
   16629            4 :   tree cast = build1 (NOP_EXPR, char_type_node, int_cst);
   16630            4 :   ASSERT_TRUE (CAN_HAVE_LOCATION_P (cast));
   16631            4 :   ASSERT_EQ (cast, maybe_wrap_with_location (cast, loc));
   16632              : 
   16633              :   /* Wrapping a STRING_CST.  */
   16634            4 :   tree string_cst = build_string (4, "foo");
   16635            4 :   ASSERT_FALSE (CAN_HAVE_LOCATION_P (string_cst));
   16636            4 :   ASSERT_FALSE (location_wrapper_p (string_cst));
   16637              : 
   16638            4 :   tree wrapped_string_cst = maybe_wrap_with_location (string_cst, loc);
   16639            4 :   ASSERT_TRUE (location_wrapper_p (wrapped_string_cst));
   16640            4 :   ASSERT_EQ (VIEW_CONVERT_EXPR, TREE_CODE (wrapped_string_cst));
   16641            4 :   ASSERT_EQ (loc, EXPR_LOCATION (wrapped_string_cst));
   16642            4 :   ASSERT_EQ (string_cst, tree_strip_any_location_wrapper (wrapped_string_cst));
   16643              : 
   16644              : 
   16645              :   /* Wrapping a variable.  */
   16646            4 :   tree int_var = build_decl (UNKNOWN_LOCATION, VAR_DECL,
   16647              :                              get_identifier ("some_int_var"),
   16648              :                              integer_type_node);
   16649            4 :   ASSERT_FALSE (CAN_HAVE_LOCATION_P (int_var));
   16650            4 :   ASSERT_FALSE (location_wrapper_p (int_var));
   16651              : 
   16652            4 :   tree wrapped_int_var = maybe_wrap_with_location (int_var, loc);
   16653            4 :   ASSERT_TRUE (location_wrapper_p (wrapped_int_var));
   16654            4 :   ASSERT_EQ (loc, EXPR_LOCATION (wrapped_int_var));
   16655            4 :   ASSERT_EQ (int_var, tree_strip_any_location_wrapper (wrapped_int_var));
   16656              : 
   16657              :   /* Verify that "reinterpret_cast<int>(some_int_var)" is not a location
   16658              :      wrapper.  */
   16659            4 :   tree r_cast = build1 (NON_LVALUE_EXPR, integer_type_node, int_var);
   16660            4 :   ASSERT_FALSE (location_wrapper_p (r_cast));
   16661            4 :   ASSERT_EQ (r_cast, tree_strip_any_location_wrapper (r_cast));
   16662              : 
   16663              :   /* Verify that STRIP_NOPS removes wrappers.  */
   16664            4 :   check_strip_nops (wrapped_int_cst, int_cst);
   16665            4 :   check_strip_nops (wrapped_string_cst, string_cst);
   16666            4 :   check_strip_nops (wrapped_int_var, int_var);
   16667            4 : }
   16668              : 
   16669              : /* Test various tree predicates.  Verify that location wrappers don't
   16670              :    affect the results.  */
   16671              : 
   16672              : static void
   16673            4 : test_predicates ()
   16674              : {
   16675              :   /* Build various constants and wrappers around them.  */
   16676              : 
   16677            4 :   location_t loc = BUILTINS_LOCATION;
   16678              : 
   16679            4 :   tree i_0 = build_int_cst (integer_type_node, 0);
   16680            4 :   tree wr_i_0 = maybe_wrap_with_location (i_0, loc);
   16681              : 
   16682            4 :   tree i_1 = build_int_cst (integer_type_node, 1);
   16683            4 :   tree wr_i_1 = maybe_wrap_with_location (i_1, loc);
   16684              : 
   16685            4 :   tree i_m1 = build_int_cst (integer_type_node, -1);
   16686            4 :   tree wr_i_m1 = maybe_wrap_with_location (i_m1, loc);
   16687              : 
   16688            4 :   tree f_0 = build_real_from_int_cst (float_type_node, i_0);
   16689            4 :   tree wr_f_0 = maybe_wrap_with_location (f_0, loc);
   16690            4 :   tree f_1 = build_real_from_int_cst (float_type_node, i_1);
   16691            4 :   tree wr_f_1 = maybe_wrap_with_location (f_1, loc);
   16692            4 :   tree f_m1 = build_real_from_int_cst (float_type_node, i_m1);
   16693            4 :   tree wr_f_m1 = maybe_wrap_with_location (f_m1, loc);
   16694              : 
   16695            4 :   tree c_i_0 = build_complex (NULL_TREE, i_0, i_0);
   16696            4 :   tree c_i_1 = build_complex (NULL_TREE, i_1, i_0);
   16697            4 :   tree c_i_m1 = build_complex (NULL_TREE, i_m1, i_0);
   16698              : 
   16699            4 :   tree c_f_0 = build_complex (NULL_TREE, f_0, f_0);
   16700            4 :   tree c_f_1 = build_complex (NULL_TREE, f_1, f_0);
   16701            4 :   tree c_f_m1 = build_complex (NULL_TREE, f_m1, f_0);
   16702              : 
   16703              :   /* TODO: vector constants.  */
   16704              : 
   16705              :   /* Test integer_onep.  */
   16706            4 :   ASSERT_FALSE (integer_onep (i_0));
   16707            4 :   ASSERT_FALSE (integer_onep (wr_i_0));
   16708            4 :   ASSERT_TRUE (integer_onep (i_1));
   16709            4 :   ASSERT_TRUE (integer_onep (wr_i_1));
   16710            4 :   ASSERT_FALSE (integer_onep (i_m1));
   16711            4 :   ASSERT_FALSE (integer_onep (wr_i_m1));
   16712            4 :   ASSERT_FALSE (integer_onep (f_0));
   16713            4 :   ASSERT_FALSE (integer_onep (wr_f_0));
   16714            4 :   ASSERT_FALSE (integer_onep (f_1));
   16715            4 :   ASSERT_FALSE (integer_onep (wr_f_1));
   16716            4 :   ASSERT_FALSE (integer_onep (f_m1));
   16717            4 :   ASSERT_FALSE (integer_onep (wr_f_m1));
   16718            4 :   ASSERT_FALSE (integer_onep (c_i_0));
   16719            4 :   ASSERT_TRUE (integer_onep (c_i_1));
   16720            4 :   ASSERT_FALSE (integer_onep (c_i_m1));
   16721            4 :   ASSERT_FALSE (integer_onep (c_f_0));
   16722            4 :   ASSERT_FALSE (integer_onep (c_f_1));
   16723            4 :   ASSERT_FALSE (integer_onep (c_f_m1));
   16724              : 
   16725              :   /* Test integer_zerop.  */
   16726            4 :   ASSERT_TRUE (integer_zerop (i_0));
   16727            4 :   ASSERT_TRUE (integer_zerop (wr_i_0));
   16728            4 :   ASSERT_FALSE (integer_zerop (i_1));
   16729            4 :   ASSERT_FALSE (integer_zerop (wr_i_1));
   16730            4 :   ASSERT_FALSE (integer_zerop (i_m1));
   16731            4 :   ASSERT_FALSE (integer_zerop (wr_i_m1));
   16732            4 :   ASSERT_FALSE (integer_zerop (f_0));
   16733            4 :   ASSERT_FALSE (integer_zerop (wr_f_0));
   16734            4 :   ASSERT_FALSE (integer_zerop (f_1));
   16735            4 :   ASSERT_FALSE (integer_zerop (wr_f_1));
   16736            4 :   ASSERT_FALSE (integer_zerop (f_m1));
   16737            4 :   ASSERT_FALSE (integer_zerop (wr_f_m1));
   16738            4 :   ASSERT_TRUE (integer_zerop (c_i_0));
   16739            4 :   ASSERT_FALSE (integer_zerop (c_i_1));
   16740            4 :   ASSERT_FALSE (integer_zerop (c_i_m1));
   16741            4 :   ASSERT_FALSE (integer_zerop (c_f_0));
   16742            4 :   ASSERT_FALSE (integer_zerop (c_f_1));
   16743            4 :   ASSERT_FALSE (integer_zerop (c_f_m1));
   16744              : 
   16745              :   /* Test integer_all_onesp.  */
   16746            4 :   ASSERT_FALSE (integer_all_onesp (i_0));
   16747            4 :   ASSERT_FALSE (integer_all_onesp (wr_i_0));
   16748            4 :   ASSERT_FALSE (integer_all_onesp (i_1));
   16749            4 :   ASSERT_FALSE (integer_all_onesp (wr_i_1));
   16750            4 :   ASSERT_TRUE (integer_all_onesp (i_m1));
   16751            4 :   ASSERT_TRUE (integer_all_onesp (wr_i_m1));
   16752            4 :   ASSERT_FALSE (integer_all_onesp (f_0));
   16753            4 :   ASSERT_FALSE (integer_all_onesp (wr_f_0));
   16754            4 :   ASSERT_FALSE (integer_all_onesp (f_1));
   16755            4 :   ASSERT_FALSE (integer_all_onesp (wr_f_1));
   16756            4 :   ASSERT_FALSE (integer_all_onesp (f_m1));
   16757            4 :   ASSERT_FALSE (integer_all_onesp (wr_f_m1));
   16758            4 :   ASSERT_FALSE (integer_all_onesp (c_i_0));
   16759            4 :   ASSERT_FALSE (integer_all_onesp (c_i_1));
   16760            4 :   ASSERT_FALSE (integer_all_onesp (c_i_m1));
   16761            4 :   ASSERT_FALSE (integer_all_onesp (c_f_0));
   16762            4 :   ASSERT_FALSE (integer_all_onesp (c_f_1));
   16763            4 :   ASSERT_FALSE (integer_all_onesp (c_f_m1));
   16764              : 
   16765              :   /* Test integer_minus_onep.  */
   16766            4 :   ASSERT_FALSE (integer_minus_onep (i_0));
   16767            4 :   ASSERT_FALSE (integer_minus_onep (wr_i_0));
   16768            4 :   ASSERT_FALSE (integer_minus_onep (i_1));
   16769            4 :   ASSERT_FALSE (integer_minus_onep (wr_i_1));
   16770            4 :   ASSERT_TRUE (integer_minus_onep (i_m1));
   16771            4 :   ASSERT_TRUE (integer_minus_onep (wr_i_m1));
   16772            4 :   ASSERT_FALSE (integer_minus_onep (f_0));
   16773            4 :   ASSERT_FALSE (integer_minus_onep (wr_f_0));
   16774            4 :   ASSERT_FALSE (integer_minus_onep (f_1));
   16775            4 :   ASSERT_FALSE (integer_minus_onep (wr_f_1));
   16776            4 :   ASSERT_FALSE (integer_minus_onep (f_m1));
   16777            4 :   ASSERT_FALSE (integer_minus_onep (wr_f_m1));
   16778            4 :   ASSERT_FALSE (integer_minus_onep (c_i_0));
   16779            4 :   ASSERT_FALSE (integer_minus_onep (c_i_1));
   16780            4 :   ASSERT_TRUE (integer_minus_onep (c_i_m1));
   16781            4 :   ASSERT_FALSE (integer_minus_onep (c_f_0));
   16782            4 :   ASSERT_FALSE (integer_minus_onep (c_f_1));
   16783            4 :   ASSERT_FALSE (integer_minus_onep (c_f_m1));
   16784              : 
   16785              :   /* Test integer_each_onep.  */
   16786            4 :   ASSERT_FALSE (integer_each_onep (i_0));
   16787            4 :   ASSERT_FALSE (integer_each_onep (wr_i_0));
   16788            4 :   ASSERT_TRUE (integer_each_onep (i_1));
   16789            4 :   ASSERT_TRUE (integer_each_onep (wr_i_1));
   16790            4 :   ASSERT_FALSE (integer_each_onep (i_m1));
   16791            4 :   ASSERT_FALSE (integer_each_onep (wr_i_m1));
   16792            4 :   ASSERT_FALSE (integer_each_onep (f_0));
   16793            4 :   ASSERT_FALSE (integer_each_onep (wr_f_0));
   16794            4 :   ASSERT_FALSE (integer_each_onep (f_1));
   16795            4 :   ASSERT_FALSE (integer_each_onep (wr_f_1));
   16796            4 :   ASSERT_FALSE (integer_each_onep (f_m1));
   16797            4 :   ASSERT_FALSE (integer_each_onep (wr_f_m1));
   16798            4 :   ASSERT_FALSE (integer_each_onep (c_i_0));
   16799            4 :   ASSERT_FALSE (integer_each_onep (c_i_1));
   16800            4 :   ASSERT_FALSE (integer_each_onep (c_i_m1));
   16801            4 :   ASSERT_FALSE (integer_each_onep (c_f_0));
   16802            4 :   ASSERT_FALSE (integer_each_onep (c_f_1));
   16803            4 :   ASSERT_FALSE (integer_each_onep (c_f_m1));
   16804              : 
   16805              :   /* Test integer_truep.  */
   16806            4 :   ASSERT_FALSE (integer_truep (i_0));
   16807            4 :   ASSERT_FALSE (integer_truep (wr_i_0));
   16808            4 :   ASSERT_TRUE (integer_truep (i_1));
   16809            4 :   ASSERT_TRUE (integer_truep (wr_i_1));
   16810            4 :   ASSERT_FALSE (integer_truep (i_m1));
   16811            4 :   ASSERT_FALSE (integer_truep (wr_i_m1));
   16812            4 :   ASSERT_FALSE (integer_truep (f_0));
   16813            4 :   ASSERT_FALSE (integer_truep (wr_f_0));
   16814            4 :   ASSERT_FALSE (integer_truep (f_1));
   16815            4 :   ASSERT_FALSE (integer_truep (wr_f_1));
   16816            4 :   ASSERT_FALSE (integer_truep (f_m1));
   16817            4 :   ASSERT_FALSE (integer_truep (wr_f_m1));
   16818            4 :   ASSERT_FALSE (integer_truep (c_i_0));
   16819            4 :   ASSERT_TRUE (integer_truep (c_i_1));
   16820            4 :   ASSERT_FALSE (integer_truep (c_i_m1));
   16821            4 :   ASSERT_FALSE (integer_truep (c_f_0));
   16822            4 :   ASSERT_FALSE (integer_truep (c_f_1));
   16823            4 :   ASSERT_FALSE (integer_truep (c_f_m1));
   16824              : 
   16825              :   /* Test integer_nonzerop.  */
   16826            4 :   ASSERT_FALSE (integer_nonzerop (i_0));
   16827            4 :   ASSERT_FALSE (integer_nonzerop (wr_i_0));
   16828            4 :   ASSERT_TRUE (integer_nonzerop (i_1));
   16829            4 :   ASSERT_TRUE (integer_nonzerop (wr_i_1));
   16830            4 :   ASSERT_TRUE (integer_nonzerop (i_m1));
   16831            4 :   ASSERT_TRUE (integer_nonzerop (wr_i_m1));
   16832            4 :   ASSERT_FALSE (integer_nonzerop (f_0));
   16833            4 :   ASSERT_FALSE (integer_nonzerop (wr_f_0));
   16834            4 :   ASSERT_FALSE (integer_nonzerop (f_1));
   16835            4 :   ASSERT_FALSE (integer_nonzerop (wr_f_1));
   16836            4 :   ASSERT_FALSE (integer_nonzerop (f_m1));
   16837            4 :   ASSERT_FALSE (integer_nonzerop (wr_f_m1));
   16838            4 :   ASSERT_FALSE (integer_nonzerop (c_i_0));
   16839            4 :   ASSERT_TRUE (integer_nonzerop (c_i_1));
   16840            4 :   ASSERT_TRUE (integer_nonzerop (c_i_m1));
   16841            4 :   ASSERT_FALSE (integer_nonzerop (c_f_0));
   16842            4 :   ASSERT_FALSE (integer_nonzerop (c_f_1));
   16843            4 :   ASSERT_FALSE (integer_nonzerop (c_f_m1));
   16844              : 
   16845              :   /* Test real_zerop.  */
   16846            4 :   ASSERT_FALSE (real_zerop (i_0));
   16847            4 :   ASSERT_FALSE (real_zerop (wr_i_0));
   16848            4 :   ASSERT_FALSE (real_zerop (i_1));
   16849            4 :   ASSERT_FALSE (real_zerop (wr_i_1));
   16850            4 :   ASSERT_FALSE (real_zerop (i_m1));
   16851            4 :   ASSERT_FALSE (real_zerop (wr_i_m1));
   16852            4 :   ASSERT_TRUE (real_zerop (f_0));
   16853            4 :   ASSERT_TRUE (real_zerop (wr_f_0));
   16854            4 :   ASSERT_FALSE (real_zerop (f_1));
   16855            4 :   ASSERT_FALSE (real_zerop (wr_f_1));
   16856            4 :   ASSERT_FALSE (real_zerop (f_m1));
   16857            4 :   ASSERT_FALSE (real_zerop (wr_f_m1));
   16858            4 :   ASSERT_FALSE (real_zerop (c_i_0));
   16859            4 :   ASSERT_FALSE (real_zerop (c_i_1));
   16860            4 :   ASSERT_FALSE (real_zerop (c_i_m1));
   16861            4 :   ASSERT_TRUE (real_zerop (c_f_0));
   16862            4 :   ASSERT_FALSE (real_zerop (c_f_1));
   16863            4 :   ASSERT_FALSE (real_zerop (c_f_m1));
   16864              : 
   16865              :   /* Test real_onep.  */
   16866            4 :   ASSERT_FALSE (real_onep (i_0));
   16867            4 :   ASSERT_FALSE (real_onep (wr_i_0));
   16868            4 :   ASSERT_FALSE (real_onep (i_1));
   16869            4 :   ASSERT_FALSE (real_onep (wr_i_1));
   16870            4 :   ASSERT_FALSE (real_onep (i_m1));
   16871            4 :   ASSERT_FALSE (real_onep (wr_i_m1));
   16872            4 :   ASSERT_FALSE (real_onep (f_0));
   16873            4 :   ASSERT_FALSE (real_onep (wr_f_0));
   16874            4 :   ASSERT_TRUE (real_onep (f_1));
   16875            4 :   ASSERT_TRUE (real_onep (wr_f_1));
   16876            4 :   ASSERT_FALSE (real_onep (f_m1));
   16877            4 :   ASSERT_FALSE (real_onep (wr_f_m1));
   16878            4 :   ASSERT_FALSE (real_onep (c_i_0));
   16879            4 :   ASSERT_FALSE (real_onep (c_i_1));
   16880            4 :   ASSERT_FALSE (real_onep (c_i_m1));
   16881            4 :   ASSERT_FALSE (real_onep (c_f_0));
   16882            4 :   ASSERT_TRUE (real_onep (c_f_1));
   16883            4 :   ASSERT_FALSE (real_onep (c_f_m1));
   16884              : 
   16885              :   /* Test real_minus_onep.  */
   16886            4 :   ASSERT_FALSE (real_minus_onep (i_0));
   16887            4 :   ASSERT_FALSE (real_minus_onep (wr_i_0));
   16888            4 :   ASSERT_FALSE (real_minus_onep (i_1));
   16889            4 :   ASSERT_FALSE (real_minus_onep (wr_i_1));
   16890            4 :   ASSERT_FALSE (real_minus_onep (i_m1));
   16891            4 :   ASSERT_FALSE (real_minus_onep (wr_i_m1));
   16892            4 :   ASSERT_FALSE (real_minus_onep (f_0));
   16893            4 :   ASSERT_FALSE (real_minus_onep (wr_f_0));
   16894            4 :   ASSERT_FALSE (real_minus_onep (f_1));
   16895            4 :   ASSERT_FALSE (real_minus_onep (wr_f_1));
   16896            4 :   ASSERT_TRUE (real_minus_onep (f_m1));
   16897            4 :   ASSERT_TRUE (real_minus_onep (wr_f_m1));
   16898            4 :   ASSERT_FALSE (real_minus_onep (c_i_0));
   16899            4 :   ASSERT_FALSE (real_minus_onep (c_i_1));
   16900            4 :   ASSERT_FALSE (real_minus_onep (c_i_m1));
   16901            4 :   ASSERT_FALSE (real_minus_onep (c_f_0));
   16902            4 :   ASSERT_FALSE (real_minus_onep (c_f_1));
   16903            4 :   ASSERT_TRUE (real_minus_onep (c_f_m1));
   16904              : 
   16905              :   /* Test zerop.  */
   16906            4 :   ASSERT_TRUE (zerop (i_0));
   16907            4 :   ASSERT_TRUE (zerop (wr_i_0));
   16908            4 :   ASSERT_FALSE (zerop (i_1));
   16909            4 :   ASSERT_FALSE (zerop (wr_i_1));
   16910            4 :   ASSERT_FALSE (zerop (i_m1));
   16911            4 :   ASSERT_FALSE (zerop (wr_i_m1));
   16912            4 :   ASSERT_TRUE (zerop (f_0));
   16913            4 :   ASSERT_TRUE (zerop (wr_f_0));
   16914            4 :   ASSERT_FALSE (zerop (f_1));
   16915            4 :   ASSERT_FALSE (zerop (wr_f_1));
   16916            4 :   ASSERT_FALSE (zerop (f_m1));
   16917            4 :   ASSERT_FALSE (zerop (wr_f_m1));
   16918            4 :   ASSERT_TRUE (zerop (c_i_0));
   16919            4 :   ASSERT_FALSE (zerop (c_i_1));
   16920            4 :   ASSERT_FALSE (zerop (c_i_m1));
   16921            4 :   ASSERT_TRUE (zerop (c_f_0));
   16922            4 :   ASSERT_FALSE (zerop (c_f_1));
   16923            4 :   ASSERT_FALSE (zerop (c_f_m1));
   16924              : 
   16925              :   /* Test tree_expr_nonnegative_p.  */
   16926            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (i_0));
   16927            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (wr_i_0));
   16928            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (i_1));
   16929            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (wr_i_1));
   16930            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (i_m1));
   16931            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (wr_i_m1));
   16932            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (f_0));
   16933            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (wr_f_0));
   16934            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (f_1));
   16935            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (wr_f_1));
   16936            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (f_m1));
   16937            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (wr_f_m1));
   16938            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_i_0));
   16939            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_i_1));
   16940            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_i_m1));
   16941            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_f_0));
   16942            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_f_1));
   16943            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_f_m1));
   16944              : 
   16945              :   /* Test tree_expr_nonzero_p.  */
   16946            4 :   ASSERT_FALSE (tree_expr_nonzero_p (i_0));
   16947            4 :   ASSERT_FALSE (tree_expr_nonzero_p (wr_i_0));
   16948            4 :   ASSERT_TRUE (tree_expr_nonzero_p (i_1));
   16949            4 :   ASSERT_TRUE (tree_expr_nonzero_p (wr_i_1));
   16950            4 :   ASSERT_TRUE (tree_expr_nonzero_p (i_m1));
   16951            4 :   ASSERT_TRUE (tree_expr_nonzero_p (wr_i_m1));
   16952              : 
   16953              :   /* Test integer_valued_real_p.  */
   16954            4 :   ASSERT_FALSE (integer_valued_real_p (i_0));
   16955            4 :   ASSERT_TRUE (integer_valued_real_p (f_0));
   16956            4 :   ASSERT_TRUE (integer_valued_real_p (wr_f_0));
   16957            4 :   ASSERT_TRUE (integer_valued_real_p (f_1));
   16958            4 :   ASSERT_TRUE (integer_valued_real_p (wr_f_1));
   16959              : 
   16960              :   /* Test integer_pow2p.  */
   16961            4 :   ASSERT_FALSE (integer_pow2p (i_0));
   16962            4 :   ASSERT_TRUE (integer_pow2p (i_1));
   16963            4 :   ASSERT_TRUE (integer_pow2p (wr_i_1));
   16964              : 
   16965              :   /* Test uniform_integer_cst_p.  */
   16966            4 :   ASSERT_TRUE (uniform_integer_cst_p (i_0));
   16967            4 :   ASSERT_TRUE (uniform_integer_cst_p (wr_i_0));
   16968            4 :   ASSERT_TRUE (uniform_integer_cst_p (i_1));
   16969            4 :   ASSERT_TRUE (uniform_integer_cst_p (wr_i_1));
   16970            4 :   ASSERT_TRUE (uniform_integer_cst_p (i_m1));
   16971            4 :   ASSERT_TRUE (uniform_integer_cst_p (wr_i_m1));
   16972            4 :   ASSERT_FALSE (uniform_integer_cst_p (f_0));
   16973            4 :   ASSERT_FALSE (uniform_integer_cst_p (wr_f_0));
   16974            4 :   ASSERT_FALSE (uniform_integer_cst_p (f_1));
   16975            4 :   ASSERT_FALSE (uniform_integer_cst_p (wr_f_1));
   16976            4 :   ASSERT_FALSE (uniform_integer_cst_p (f_m1));
   16977            4 :   ASSERT_FALSE (uniform_integer_cst_p (wr_f_m1));
   16978            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_i_0));
   16979            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_i_1));
   16980            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_i_m1));
   16981            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_f_0));
   16982            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_f_1));
   16983            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_f_m1));
   16984            4 : }
   16985              : 
   16986              : /* Check that string escaping works correctly.  */
   16987              : 
   16988              : static void
   16989            4 : test_escaped_strings (void)
   16990              : {
   16991            4 :   int saved_cutoff;
   16992            4 :   escaped_string msg;
   16993              : 
   16994            4 :   msg.escape (NULL);
   16995              :   /* ASSERT_STREQ does not accept NULL as a valid test
   16996              :      result, so we have to use ASSERT_EQ instead.  */
   16997            4 :   ASSERT_EQ (NULL, (const char *) msg);
   16998              : 
   16999            4 :   msg.escape ("");
   17000            4 :   ASSERT_STREQ ("", (const char *) msg);
   17001              : 
   17002            4 :   msg.escape ("foobar");
   17003            4 :   ASSERT_STREQ ("foobar", (const char *) msg);
   17004              : 
   17005              :   /* Ensure that we have -fmessage-length set to 0.  */
   17006            4 :   pretty_printer *pp = global_dc->get_reference_printer ();
   17007            4 :   saved_cutoff = pp_line_cutoff (pp);
   17008            4 :   pp_line_cutoff (pp) = 0;
   17009              : 
   17010            4 :   msg.escape ("foo\nbar");
   17011            4 :   ASSERT_STREQ ("foo\\nbar", (const char *) msg);
   17012              : 
   17013            4 :   msg.escape ("\a\b\f\n\r\t\v");
   17014            4 :   ASSERT_STREQ ("\\a\\b\\f\\n\\r\\t\\v", (const char *) msg);
   17015              : 
   17016              :   /* Now repeat the tests with -fmessage-length set to 5.  */
   17017            4 :   pp_line_cutoff (pp) = 5;
   17018              : 
   17019              :   /* Note that the newline is not translated into an escape.  */
   17020            4 :   msg.escape ("foo\nbar");
   17021            4 :   ASSERT_STREQ ("foo\nbar", (const char *) msg);
   17022              : 
   17023            4 :   msg.escape ("\a\b\f\n\r\t\v");
   17024            4 :   ASSERT_STREQ ("\\a\\b\\f\n\\r\\t\\v", (const char *) msg);
   17025              : 
   17026              :   /* Restore the original message length setting.  */
   17027            4 :   pp_line_cutoff (pp) = saved_cutoff;
   17028            4 : }
   17029              : 
   17030              : /* Run all of the selftests within this file.  */
   17031              : 
   17032              : void
   17033            4 : tree_cc_tests ()
   17034              : {
   17035            4 :   test_integer_constants ();
   17036            4 :   test_identifiers ();
   17037            4 :   test_labels ();
   17038            4 :   test_vector_cst_patterns ();
   17039            4 :   test_location_wrappers ();
   17040            4 :   test_predicates ();
   17041            4 :   test_escaped_strings ();
   17042            4 : }
   17043              : 
   17044              : } // namespace selftest
   17045              : 
   17046              : #endif /* CHECKING_P */
   17047              : 
   17048              : #include "gt-tree.h"
        

Generated by: LCOV version 2.5.0-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.