LCOV - code coverage report
Current view: top level - gcc - gimple.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 87.3 % 1610 1406
Test Date: 2026-12-05 16:10:02 Functions: 96.5 % 143 138
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Gimple IR support functions.
       2              : 
       3              :    Copyright (C) 2007-2026 Free Software Foundation, Inc.
       4              :    Contributed by Aldy Hernandez <aldyh@redhat.com>
       5              : 
       6              : This file is part of GCC.
       7              : 
       8              : GCC is free software; you can redistribute it and/or modify it under
       9              : the terms of the GNU General Public License as published by the Free
      10              : Software Foundation; either version 3, or (at your option) any later
      11              : version.
      12              : 
      13              : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      14              : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      15              : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      16              : for more details.
      17              : 
      18              : You should have received a copy of the GNU General Public License
      19              : along with GCC; see the file COPYING3.  If not see
      20              : <http://www.gnu.org/licenses/>.  */
      21              : 
      22              : #include "config.h"
      23              : #include "system.h"
      24              : #include "coretypes.h"
      25              : #include "backend.h"
      26              : #include "tree.h"
      27              : #include "gimple.h"
      28              : #include "ssa.h"
      29              : #include "cgraph.h"
      30              : #include "diagnostic.h"
      31              : #include "alias.h"
      32              : #include "fold-const.h"
      33              : #include "calls.h"
      34              : #include "stor-layout.h"
      35              : #include "internal-fn.h"
      36              : #include "tree-eh.h"
      37              : #include "gimple-iterator.h"
      38              : #include "gimple-walk.h"
      39              : #include "gimplify.h"
      40              : #include "target.h"
      41              : #include "builtins.h"
      42              : #include "selftest.h"
      43              : #include "gimple-pretty-print.h"
      44              : #include "stringpool.h"
      45              : #include "attribs.h"
      46              : #include "asan.h"
      47              : #include "ubsan.h"
      48              : #include "langhooks.h"
      49              : #include "attr-fnspec.h"
      50              : #include "ipa-modref-tree.h"
      51              : #include "ipa-modref.h"
      52              : #include "dbgcnt.h"
      53              : 
      54              : /* All the tuples have their operand vector (if present) at the very bottom of
      55              :    the structure.  Therefore, the offset required to find the operands vector is
      56              :    the size of the structure minus the size of the 1-element tree array at the
      57              :    end (see gimple_ops).  An adjustment may be required if there is tail
      58              :    padding, as may happen on a host (e.g. sparc) where a pointer has 4-byte
      59              :    alignment while a uint64_t has 8-byte alignment.
      60              : 
      61              :    Unfortunately, we can't use offsetof to do this computation 100%
      62              :    straightforwardly, because these structs use inheritance and so are not
      63              :    standard layout types.  However, the fact that they are not standard layout
      64              :    types also means that tail padding will be reused in inheritance, which makes
      65              :    it possible to check for the problematic case with the following logic
      66              :    instead.  If tail padding is detected, the offset should be decreased
      67              :    accordingly.  */
      68              : 
      69              : template<typename G>
      70              : static constexpr size_t
      71              : get_tail_padding_adjustment ()
      72              : {
      73              :   struct padding_check : G
      74              :   {
      75              :     tree t;
      76              :   };
      77              :   return sizeof (padding_check) == sizeof (G) ? sizeof (tree) : 0;
      78              : }
      79              : 
      80              : #define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) \
      81              :   (HAS_TREE_OP \
      82              :    ? sizeof (STRUCT) - sizeof (tree) - get_tail_padding_adjustment<STRUCT> () \
      83              :    : 0),
      84              : EXPORTED_CONST size_t gimple_ops_offset_[] = {
      85              : #include "gsstruct.def"
      86              : };
      87              : #undef DEFGSSTRUCT
      88              : 
      89              : #define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) sizeof (struct STRUCT),
      90              : static const size_t gsstruct_code_size[] = {
      91              : #include "gsstruct.def"
      92              : };
      93              : #undef DEFGSSTRUCT
      94              : 
      95              : #define DEFGSCODE(SYM, NAME, GSSCODE)   NAME,
      96              : const char *const gimple_code_name[] = {
      97              : #include "gimple.def"
      98              : };
      99              : #undef DEFGSCODE
     100              : 
     101              : #define DEFGSCODE(SYM, NAME, GSSCODE)   GSSCODE,
     102              : EXPORTED_CONST enum gimple_statement_structure_enum gss_for_code_[] = {
     103              : #include "gimple.def"
     104              : };
     105              : #undef DEFGSCODE
     106              : 
     107              : /* Gimple stats.  */
     108              : 
     109              : uint64_t gimple_alloc_counts[(int) gimple_alloc_kind_all];
     110              : uint64_t gimple_alloc_sizes[(int) gimple_alloc_kind_all];
     111              : 
     112              : /* Keep in sync with gimple.h:enum gimple_alloc_kind.  */
     113              : static const char * const gimple_alloc_kind_names[] = {
     114              :     "assignments",
     115              :     "phi nodes",
     116              :     "conditionals",
     117              :     "everything else"
     118              : };
     119              : 
     120              : /* Static gimple tuple members.  */
     121              : const enum gimple_code gassign::code_;
     122              : const enum gimple_code gcall::code_;
     123              : const enum gimple_code gcond::code_;
     124              : 
     125              : 
     126              : /* Gimple tuple constructors.
     127              :    Note: Any constructor taking a ``gimple_seq'' as a parameter, can
     128              :    be passed a NULL to start with an empty sequence.  */
     129              : 
     130              : /* Set the code for statement G to CODE.  */
     131              : 
     132              : static inline void
     133    335013414 : gimple_set_code (gimple *g, enum gimple_code code)
     134              : {
     135    335013414 :   g->code = code;
     136              : }
     137              : 
     138              : /* Return the number of bytes needed to hold a GIMPLE statement with
     139              :    code CODE.  */
     140              : 
     141              : size_t
     142    410468611 : gimple_size (enum gimple_code code, unsigned num_ops)
     143              : {
     144    410468611 :   size_t size = gsstruct_code_size[gss_for_code (code)];
     145    410468611 :   if (num_ops > 0)
     146    280739908 :     size += (sizeof (tree) * (num_ops - 1));
     147    410468611 :   return size;
     148              : }
     149              : 
     150              : /* Initialize GIMPLE statement G with CODE and NUM_OPS.  */
     151              : 
     152              : void
     153    335013414 : gimple_init (gimple *g, enum gimple_code code, unsigned num_ops)
     154              : {
     155    335013414 :   gimple_set_code (g, code);
     156    335013414 :   gimple_set_num_ops (g, num_ops);
     157              : 
     158              :   /* Do not call gimple_set_modified here as it has other side
     159              :      effects and this tuple is still not completely built.  */
     160    335013414 :   g->modified = 1;
     161    335013414 :   gimple_init_singleton (g);
     162    335013414 : }
     163              : 
     164              : /* Allocate memory for a GIMPLE statement with code CODE and NUM_OPS
     165              :    operands.  */
     166              : 
     167              : gimple *
     168    333317038 : gimple_alloc (enum gimple_code code, unsigned num_ops MEM_STAT_DECL)
     169              : {
     170    333317038 :   size_t size;
     171    333317038 :   gimple *stmt;
     172              : 
     173    333317038 :   size = gimple_size (code, num_ops);
     174    333317038 :   if (GATHER_STATISTICS)
     175              :     {
     176              :       enum gimple_alloc_kind kind = gimple_alloc_kind (code);
     177              :       gimple_alloc_counts[(int) kind]++;
     178              :       gimple_alloc_sizes[(int) kind] += size;
     179              :     }
     180              : 
     181    333317038 :   stmt = ggc_alloc_cleared_gimple_statement_stat (size PASS_MEM_STAT);
     182    333317038 :   gimple_init (stmt, code, num_ops);
     183    333317038 :   return stmt;
     184              : }
     185              : 
     186              : /* Set SUBCODE to be the code of the expression computed by statement G.  */
     187              : 
     188              : static inline void
     189    238073197 : gimple_set_subcode (gimple *g, unsigned subcode)
     190              : {
     191              :   /* We only have 16 bits for the RHS code.  Assert that we are not
     192              :      overflowing it.  */
     193    238073197 :   gcc_assert (subcode < (1 << 16));
     194    238073197 :   g->subcode = subcode;
     195    238073197 : }
     196              : 
     197              : 
     198              : 
     199              : /* Build a tuple with operands.  CODE is the statement to build (which
     200              :    must be one of the GIMPLE_WITH_OPS tuples).  SUBCODE is the subcode
     201              :    for the new tuple.  NUM_OPS is the number of operands to allocate.  */
     202              : 
     203              : #define gimple_build_with_ops(c, s, n) \
     204              :   gimple_build_with_ops_stat (c, s, n MEM_STAT_INFO)
     205              : 
     206              : static gimple *
     207    226713664 : gimple_build_with_ops_stat (enum gimple_code code, unsigned subcode,
     208              :                             unsigned num_ops MEM_STAT_DECL)
     209              : {
     210            0 :   gimple *s = gimple_alloc (code, num_ops PASS_MEM_STAT);
     211    226713664 :   gimple_set_subcode (s, subcode);
     212              : 
     213    226713664 :   return s;
     214              : }
     215              : 
     216              : 
     217              : /* Build a GIMPLE_RETURN statement returning RETVAL.  */
     218              : 
     219              : greturn *
     220      3676119 : gimple_build_return (tree retval)
     221              : {
     222      3676119 :   greturn *s
     223      3676119 :     = as_a <greturn *> (gimple_build_with_ops (GIMPLE_RETURN, ERROR_MARK,
     224              :                                                2));
     225      3676119 :   if (retval)
     226      2225947 :     gimple_return_set_retval (s, retval);
     227      3676119 :   return s;
     228              : }
     229              : 
     230              : /* Reset alias information on call S.  */
     231              : 
     232              : void
     233     18813997 : gimple_call_reset_alias_info (gcall *s)
     234              : {
     235     18813997 :   if (gimple_call_flags (s) & ECF_CONST)
     236      2396069 :     memset (gimple_call_use_set (s), 0, sizeof (struct pt_solution));
     237              :   else
     238     16417928 :     pt_solution_reset (gimple_call_use_set (s));
     239     18813997 :   if (gimple_call_flags (s) & (ECF_CONST|ECF_PURE|ECF_NOVOPS))
     240      3639419 :     memset (gimple_call_clobber_set (s), 0, sizeof (struct pt_solution));
     241              :   else
     242     15174578 :     pt_solution_reset (gimple_call_clobber_set (s));
     243     18813997 : }
     244              : 
     245              : /* Helper for gimple_build_call, gimple_build_call_valist,
     246              :    gimple_build_call_vec and gimple_build_call_from_tree.  Build the basic
     247              :    components of a GIMPLE_CALL statement to function FN with NARGS
     248              :    arguments.  */
     249              : 
     250              : static inline gcall *
     251     12350848 : gimple_build_call_1 (tree fn, unsigned nargs)
     252              : {
     253     12350848 :   gcall *s
     254     24701696 :     = as_a <gcall *> (gimple_build_with_ops (GIMPLE_CALL, ERROR_MARK,
     255              :                                              nargs + 3));
     256     12350848 :   if (TREE_CODE (fn) == FUNCTION_DECL)
     257     12126961 :     fn = build_fold_addr_expr (fn);
     258     12350848 :   gimple_set_op (s, 1, fn);
     259     12350848 :   gimple_call_set_fntype (s, TREE_TYPE (TREE_TYPE (fn)));
     260     12350848 :   gimple_call_reset_alias_info (s);
     261     12350848 :   return s;
     262              : }
     263              : 
     264              : 
     265              : /* Build a GIMPLE_CALL statement to function FN with the arguments
     266              :    specified in vector ARGS.  */
     267              : 
     268              : gcall *
     269       759802 : gimple_build_call_vec (tree fn, const vec<tree> &args)
     270              : {
     271       759802 :   unsigned i;
     272       759802 :   unsigned nargs = args.length ();
     273       759802 :   gcall *call = gimple_build_call_1 (fn, nargs);
     274              : 
     275      3366233 :   for (i = 0; i < nargs; i++)
     276      1846629 :     gimple_call_set_arg (call, i, args[i]);
     277              : 
     278       759802 :   return call;
     279              : }
     280              : 
     281              : 
     282              : /* Build a GIMPLE_CALL statement to function FN.  NARGS is the number of
     283              :    arguments.  The ... are the arguments.  */
     284              : 
     285              : gcall *
     286       653429 : gimple_build_call (tree fn, unsigned nargs, ...)
     287              : {
     288       653429 :   va_list ap;
     289       653429 :   gcall *call;
     290       653429 :   unsigned i;
     291              : 
     292       653429 :   gcc_assert (TREE_CODE (fn) == FUNCTION_DECL || is_gimple_call_addr (fn));
     293              : 
     294       653429 :   call = gimple_build_call_1 (fn, nargs);
     295              : 
     296       653429 :   va_start (ap, nargs);
     297      1351052 :   for (i = 0; i < nargs; i++)
     298       697623 :     gimple_call_set_arg (call, i, va_arg (ap, tree));
     299       653429 :   va_end (ap);
     300              : 
     301       653429 :   return call;
     302              : }
     303              : 
     304              : 
     305              : /* Build a GIMPLE_CALL statement to function FN.  NARGS is the number of
     306              :    arguments.  AP contains the arguments.  */
     307              : 
     308              : gcall *
     309         2476 : gimple_build_call_valist (tree fn, unsigned nargs, va_list ap)
     310              : {
     311         2476 :   gcall *call;
     312         2476 :   unsigned i;
     313              : 
     314         2476 :   gcc_assert (TREE_CODE (fn) == FUNCTION_DECL || is_gimple_call_addr (fn));
     315              : 
     316         2476 :   call = gimple_build_call_1 (fn, nargs);
     317              : 
     318        12055 :   for (i = 0; i < nargs; i++)
     319         7103 :     gimple_call_set_arg (call, i, va_arg (ap, tree));
     320              : 
     321         2476 :   return call;
     322              : }
     323              : 
     324              : 
     325              : /* Helper for gimple_build_call_internal and gimple_build_call_internal_vec.
     326              :    Build the basic components of a GIMPLE_CALL statement to internal
     327              :    function FN with NARGS arguments.  */
     328              : 
     329              : gcall *
     330       889112 : gimple_build_call_internal_1 (enum internal_fn fn, unsigned nargs)
     331              : {
     332       889112 :   gcall *s
     333      1778224 :     = as_a <gcall *> (gimple_build_with_ops (GIMPLE_CALL, ERROR_MARK,
     334              :                                              nargs + 3));
     335       889112 :   s->subcode |= GF_CALL_INTERNAL;
     336       889112 :   gimple_call_set_internal_fn (s, fn);
     337       889112 :   gimple_call_reset_alias_info (s);
     338       889112 :   return s;
     339              : }
     340              : 
     341              : 
     342              : /* Build a GIMPLE_CALL statement to internal function FN.  NARGS is
     343              :    the number of arguments.  The ... are the arguments.  */
     344              : 
     345              : gcall *
     346       496210 : gimple_build_call_internal (enum internal_fn fn, unsigned nargs, ...)
     347              : {
     348       496210 :   va_list ap;
     349       496210 :   gcall *call;
     350       496210 :   unsigned i;
     351              : 
     352       496210 :   call = gimple_build_call_internal_1 (fn, nargs);
     353       496210 :   va_start (ap, nargs);
     354      1999751 :   for (i = 0; i < nargs; i++)
     355      1503541 :     gimple_call_set_arg (call, i, va_arg (ap, tree));
     356       496210 :   va_end (ap);
     357              : 
     358       496210 :   return call;
     359              : }
     360              : 
     361              : 
     362              : /* Build a GIMPLE_CALL statement to internal function FN with the arguments
     363              :    specified in vector ARGS.  */
     364              : 
     365              : gcall *
     366       392758 : gimple_build_call_internal_vec (enum internal_fn fn, const vec<tree> &args)
     367              : {
     368       392758 :   unsigned i, nargs;
     369       392758 :   gcall *call;
     370              : 
     371       392758 :   nargs = args.length ();
     372       392758 :   call = gimple_build_call_internal_1 (fn, nargs);
     373      1952579 :   for (i = 0; i < nargs; i++)
     374      1167063 :     gimple_call_set_arg (call, i, args[i]);
     375              : 
     376       392758 :   return call;
     377              : }
     378              : 
     379              : 
     380              : /* Build a GIMPLE_CALL statement from CALL_EXPR T.  Note that T is
     381              :    assumed to be in GIMPLE form already.  Minimal checking is done of
     382              :    this fact.  */
     383              : 
     384              : gcall *
     385     10935285 : gimple_build_call_from_tree (tree t, tree fnptrtype)
     386              : {
     387     10935285 :   unsigned i, nargs;
     388     10935285 :   gcall *call;
     389              : 
     390     10935285 :   gcc_assert (TREE_CODE (t) == CALL_EXPR);
     391              : 
     392     10935285 :   nargs = call_expr_nargs (t);
     393              : 
     394     10935285 :   tree fndecl = NULL_TREE;
     395     10935285 :   if (CALL_EXPR_FN (t) == NULL_TREE)
     396          144 :     call = gimple_build_call_internal_1 (CALL_EXPR_IFN (t), nargs);
     397              :   else
     398              :     {
     399     10935141 :       fndecl = get_callee_fndecl (t);
     400     11101057 :       call = gimple_build_call_1 (fndecl ? fndecl : CALL_EXPR_FN (t), nargs);
     401              :     }
     402              : 
     403     30564574 :   for (i = 0; i < nargs; i++)
     404     19629289 :     gimple_call_set_arg (call, i, CALL_EXPR_ARG (t, i));
     405              : 
     406     10935285 :   gimple_set_block (call, TREE_BLOCK (t));
     407     10935285 :   gimple_set_location (call, EXPR_LOCATION (t));
     408              : 
     409              :   /* Carry all the CALL_EXPR flags to the new GIMPLE_CALL.  */
     410     10935285 :   gimple_call_set_chain (call, CALL_EXPR_STATIC_CHAIN (t));
     411     10935285 :   gimple_call_set_tail (call, CALL_EXPR_TAILCALL (t));
     412     10935285 :   gimple_call_set_must_tail (call, CALL_EXPR_MUST_TAIL_CALL (t));
     413     10935285 :   gimple_call_set_return_slot_opt (call, CALL_EXPR_RETURN_SLOT_OPT (t));
     414     10935285 :   if (fndecl
     415     10769225 :       && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
     416     13268031 :       && ALLOCA_FUNCTION_CODE_P (DECL_FUNCTION_CODE (fndecl)))
     417        83648 :     gimple_call_set_alloca_for_var (call, CALL_ALLOCA_FOR_VAR_P (t));
     418     10893461 :   else if (fndecl
     419     21620862 :            && (DECL_IS_OPERATOR_NEW_P (fndecl)
     420     10671927 :                || DECL_IS_OPERATOR_DELETE_P (fndecl)))
     421       263874 :     gimple_call_set_from_new_or_delete (call, CALL_FROM_NEW_OR_DELETE_P (t));
     422              :   else
     423     21523048 :     gimple_call_set_from_thunk (call, CALL_FROM_THUNK_P (t));
     424     10935285 :   gimple_call_set_va_arg_pack (call, CALL_EXPR_VA_ARG_PACK (t));
     425     10935285 :   gimple_call_set_nothrow (call, TREE_NOTHROW (t));
     426     10935285 :   if (fndecl)
     427     10769225 :     gimple_call_set_expected_throw (call,
     428     10769225 :                                     flags_from_decl_or_type (fndecl)
     429     10769225 :                                     & ECF_XTHROW);
     430     10935285 :   gimple_call_set_by_descriptor (call, CALL_EXPR_BY_DESCRIPTOR (t));
     431     10935285 :   copy_warning (call, t);
     432              : 
     433     10935285 :   if (fnptrtype)
     434              :     {
     435     10935004 :       gimple_call_set_fntype (call, TREE_TYPE (fnptrtype));
     436              : 
     437              :       /* Check if it's an indirect CALL and the type has the
     438              :          nocf_check attribute. In that case propagate the information
     439              :          to the gimple CALL insn.  */
     440     10935004 :       if (!fndecl)
     441              :         {
     442       165779 :           gcc_assert (POINTER_TYPE_P (fnptrtype));
     443       165779 :           tree fntype = TREE_TYPE (fnptrtype);
     444              : 
     445       165779 :           if (lookup_attribute ("nocf_check", TYPE_ATTRIBUTES (fntype)))
     446           21 :             gimple_call_set_nocf_check (call, true);
     447              :         }
     448              :     }
     449              : 
     450     10935285 :   return call;
     451              : }
     452              : 
     453              : /* Build a gcall to __builtin_unreachable as rewritten by
     454              :    -fsanitize=unreachable.  */
     455              : 
     456              : gcall *
     457       192920 : gimple_build_builtin_unreachable (location_t loc)
     458              : {
     459       192920 :   tree data = NULL_TREE;
     460       192920 :   tree fn = sanitize_unreachable_fn (&data, loc);
     461       192920 :   gcall *g = gimple_build_call (fn, data != NULL_TREE, data);
     462       192920 :   gimple_call_set_ctrl_altering (g, true);
     463       192920 :   gimple_set_location (g, loc);
     464       192920 :   return g;
     465              : }
     466              : 
     467              : /* Build a GIMPLE_ASSIGN statement.
     468              : 
     469              :    LHS of the assignment.
     470              :    RHS of the assignment which can be unary or binary.  */
     471              : 
     472              : gassign *
     473     90045800 : gimple_build_assign (tree lhs, tree rhs MEM_STAT_DECL)
     474              : {
     475     90045800 :   enum tree_code subcode;
     476     90045800 :   tree op1, op2, op3;
     477              : 
     478     90045800 :   extract_ops_from_tree (rhs, &subcode, &op1, &op2, &op3);
     479     90045800 :   return gimple_build_assign (lhs, subcode, op1, op2, op3 PASS_MEM_STAT);
     480              : }
     481              : 
     482              : 
     483              : /* Build a GIMPLE_ASSIGN statement with subcode SUBCODE and operands
     484              :    OP1, OP2 and OP3.  */
     485              : 
     486              : static inline gassign *
     487     96528037 : gimple_build_assign_1 (tree lhs, enum tree_code subcode, tree op1,
     488              :                        tree op2, tree op3 MEM_STAT_DECL)
     489              : {
     490     96528037 :   unsigned num_ops;
     491     96528037 :   gassign *p;
     492              : 
     493              :   /* Need 1 operand for LHS and 1 or 2 for the RHS (depending on the
     494              :      code).  */
     495     96528037 :   num_ops = get_gimple_rhs_num_ops (subcode) + 1;
     496              : 
     497    193056074 :   p = as_a <gassign *> (
     498              :         gimple_build_with_ops_stat (GIMPLE_ASSIGN, (unsigned)subcode, num_ops
     499              :                                     PASS_MEM_STAT));
     500     96528037 :   gimple_assign_set_lhs (p, lhs);
     501              :   /* For COND_EXPR, op1 should not be a comparison. */
     502     96528037 :   if (op1 && subcode == COND_EXPR)
     503       218631 :     gcc_assert (!COMPARISON_CLASS_P  (op1));
     504     96528037 :   gimple_assign_set_rhs1 (p, op1);
     505     96528037 :   if (op2)
     506              :     {
     507     15193469 :       gcc_assert (num_ops > 2);
     508     15193469 :       gimple_assign_set_rhs2 (p, op2);
     509              :     }
     510              : 
     511     96528037 :   if (op3)
     512              :     {
     513       336046 :       gcc_assert (num_ops > 3);
     514       336046 :       gimple_assign_set_rhs3 (p, op3);
     515              :     }
     516              : 
     517     96528037 :   return p;
     518              : }
     519              : 
     520              : /* Build a GIMPLE_ASSIGN statement with subcode SUBCODE and operands
     521              :    OP1, OP2 and OP3.  */
     522              : 
     523              : gassign *
     524     91399260 : gimple_build_assign (tree lhs, enum tree_code subcode, tree op1,
     525              :                      tree op2, tree op3 MEM_STAT_DECL)
     526              : {
     527     91399260 :   return gimple_build_assign_1 (lhs, subcode, op1, op2, op3 PASS_MEM_STAT);
     528              : }
     529              : 
     530              : /* Build a GIMPLE_ASSIGN statement with subcode SUBCODE and operands
     531              :    OP1 and OP2.  */
     532              : 
     533              : gassign *
     534      3584406 : gimple_build_assign (tree lhs, enum tree_code subcode, tree op1,
     535              :                      tree op2 MEM_STAT_DECL)
     536              : {
     537      3584406 :   return gimple_build_assign_1 (lhs, subcode, op1, op2, NULL_TREE
     538      3584406 :                                 PASS_MEM_STAT);
     539              : }
     540              : 
     541              : /* Build a GIMPLE_ASSIGN statement with subcode SUBCODE and operand OP1.  */
     542              : 
     543              : gassign *
     544      1544371 : gimple_build_assign (tree lhs, enum tree_code subcode, tree op1 MEM_STAT_DECL)
     545              : {
     546      1544371 :   return gimple_build_assign_1 (lhs, subcode, op1, NULL_TREE, NULL_TREE
     547      1544371 :                                 PASS_MEM_STAT);
     548              : }
     549              : 
     550              : 
     551              : /* Build a GIMPLE_COND statement.
     552              : 
     553              :    PRED is the condition used to compare LHS and the RHS.
     554              :    T_LABEL is the label to jump to if the condition is true.
     555              :    F_LABEL is the label to jump to otherwise.  */
     556              : 
     557              : gcond *
     558      8862358 : gimple_build_cond (enum tree_code pred_code, tree lhs, tree rhs,
     559              :                    tree t_label, tree f_label)
     560              : {
     561      8862358 :   gcond *p;
     562              : 
     563      8862358 :   gcc_assert (TREE_CODE_CLASS (pred_code) == tcc_comparison);
     564     17724716 :   p = as_a <gcond *> (gimple_build_with_ops (GIMPLE_COND, pred_code, 4));
     565      8862358 :   gimple_cond_set_lhs (p, lhs);
     566      8862358 :   gimple_cond_set_rhs (p, rhs);
     567      8862358 :   gimple_cond_set_true_label (p, t_label);
     568      8862358 :   gimple_cond_set_false_label (p, f_label);
     569      8862358 :   return p;
     570              : }
     571              : 
     572              : /* Build a GIMPLE_COND statement from the conditional expression tree
     573              :    COND.  T_LABEL and F_LABEL are as in gimple_build_cond.  */
     574              : 
     575              : gcond *
     576       103542 : gimple_build_cond_from_tree (tree cond, tree t_label, tree f_label)
     577              : {
     578       103542 :   enum tree_code code;
     579       103542 :   tree lhs, rhs;
     580              : 
     581       103542 :   gimple_cond_get_ops_from_tree (cond, &code, &lhs, &rhs);
     582       103542 :   return gimple_build_cond (code, lhs, rhs, t_label, f_label);
     583              : }
     584              : 
     585              : /* Set code, lhs, and rhs of a GIMPLE_COND from a suitable
     586              :    boolean expression tree COND.  */
     587              : 
     588              : void
     589       413204 : gimple_cond_set_condition_from_tree (gcond *stmt, tree cond)
     590              : {
     591       413204 :   enum tree_code code;
     592       413204 :   tree lhs, rhs;
     593              : 
     594       413204 :   gimple_cond_get_ops_from_tree (cond, &code, &lhs, &rhs);
     595       413204 :   gimple_cond_set_condition (stmt, code, lhs, rhs);
     596       413204 : }
     597              : 
     598              : /* Build a GIMPLE_LABEL statement for LABEL.  */
     599              : 
     600              : glabel *
     601     19755151 : gimple_build_label (tree label)
     602              : {
     603     19755151 :   glabel *p
     604     19755151 :     = as_a <glabel *> (gimple_build_with_ops (GIMPLE_LABEL, ERROR_MARK, 1));
     605     19755151 :   gimple_label_set_label (p, label);
     606     19755151 :   return p;
     607              : }
     608              : 
     609              : /* Build a GIMPLE_GOTO statement to label DEST.  */
     610              : 
     611              : ggoto *
     612      7222005 : gimple_build_goto (tree dest)
     613              : {
     614      7222005 :   ggoto *p
     615      7222005 :     = as_a <ggoto *> (gimple_build_with_ops (GIMPLE_GOTO, ERROR_MARK, 1));
     616      7222005 :   gimple_goto_set_dest (p, dest);
     617      7222005 :   return p;
     618              : }
     619              : 
     620              : 
     621              : /* Build a GIMPLE_NOP statement.  */
     622              : 
     623              : gimple *
     624     15915869 : gimple_build_nop (void)
     625              : {
     626     15915869 :   return gimple_alloc (GIMPLE_NOP, 0);
     627              : }
     628              : 
     629              : 
     630              : /* Build a GIMPLE_BIND statement.
     631              :    VARS are the variables in BODY.
     632              :    BLOCK is the containing block.  */
     633              : 
     634              : gbind *
     635      7589192 : gimple_build_bind (tree vars, gimple_seq body, tree block)
     636              : {
     637      7589192 :   gbind *p = as_a <gbind *> (gimple_alloc (GIMPLE_BIND, 0));
     638      7589192 :   gimple_bind_set_vars (p, vars);
     639      7589192 :   if (body)
     640      1341752 :     gimple_bind_set_body (p, body);
     641      7589192 :   if (block)
     642      6100087 :     gimple_bind_set_block (p, block);
     643      7589192 :   return p;
     644              : }
     645              : 
     646              : /* Helper function to set the simple fields of a asm stmt.
     647              : 
     648              :    STRING is a pointer to a string that is the asm blocks assembly code.
     649              :    NINPUT is the number of register inputs.
     650              :    NOUTPUT is the number of register outputs.
     651              :    NCLOBBERS is the number of clobbered registers.
     652              :    */
     653              : 
     654              : static inline gasm *
     655        88378 : gimple_build_asm_1 (const char *string, unsigned ninputs, unsigned noutputs,
     656              :                     unsigned nclobbers, unsigned nlabels)
     657              : {
     658        88378 :   gasm *p;
     659        88378 :   int size = strlen (string);
     660              : 
     661        88378 :   p = as_a <gasm *> (
     662        88378 :         gimple_build_with_ops (GIMPLE_ASM, ERROR_MARK,
     663              :                                ninputs + noutputs + nclobbers + nlabels));
     664              : 
     665        88378 :   p->ni = ninputs;
     666        88378 :   p->no = noutputs;
     667        88378 :   p->nc = nclobbers;
     668        88378 :   p->nl = nlabels;
     669        88378 :   p->string = ggc_alloc_string (string, size);
     670              : 
     671        88378 :   if (GATHER_STATISTICS)
     672              :     gimple_alloc_sizes[(int) gimple_alloc_kind (GIMPLE_ASM)] += size;
     673              : 
     674        88378 :   return p;
     675              : }
     676              : 
     677              : /* Build a GIMPLE_ASM statement.
     678              : 
     679              :    STRING is the assembly code.
     680              :    NINPUT is the number of register inputs.
     681              :    NOUTPUT is the number of register outputs.
     682              :    NCLOBBERS is the number of clobbered registers.
     683              :    INPUTS is a vector of the input register parameters.
     684              :    OUTPUTS is a vector of the output register parameters.
     685              :    CLOBBERS is a vector of the clobbered register parameters.
     686              :    LABELS is a vector of destination labels.  */
     687              : 
     688              : gasm *
     689        88378 : gimple_build_asm_vec (const char *string, vec<tree, va_gc> *inputs,
     690              :                       vec<tree, va_gc> *outputs, vec<tree, va_gc> *clobbers,
     691              :                       vec<tree, va_gc> *labels)
     692              : {
     693        88378 :   gasm *p;
     694        88378 :   unsigned i;
     695              : 
     696       173098 :   p = gimple_build_asm_1 (string,
     697              :                           vec_safe_length (inputs),
     698              :                           vec_safe_length (outputs),
     699              :                           vec_safe_length (clobbers),
     700              :                           vec_safe_length (labels));
     701              : 
     702       306224 :   for (i = 0; i < vec_safe_length (inputs); i++)
     703        47776 :     gimple_asm_set_input_op (p, i, (*inputs)[i]);
     704              : 
     705       253638 :   for (i = 0; i < vec_safe_length (outputs); i++)
     706        67176 :     gimple_asm_set_output_op (p, i, (*outputs)[i]);
     707              : 
     708       303144 :   for (i = 0; i < vec_safe_length (clobbers); i++)
     709        80787 :     gimple_asm_set_clobber_op (p, i, (*clobbers)[i]);
     710              : 
     711        89337 :   for (i = 0; i < vec_safe_length (labels); i++)
     712          959 :     gimple_asm_set_label_op (p, i, (*labels)[i]);
     713              : 
     714        88378 :   return p;
     715              : }
     716              : 
     717              : /* Build a GIMPLE_CATCH statement.
     718              : 
     719              :   TYPES are the catch types.
     720              :   HANDLER is the exception handler.  */
     721              : 
     722              : gcatch *
     723        43036 : gimple_build_catch (tree types, gimple_seq handler)
     724              : {
     725        43036 :   gcatch *p = as_a <gcatch *> (gimple_alloc (GIMPLE_CATCH, 0));
     726        43036 :   gimple_catch_set_types (p, types);
     727        43036 :   if (handler)
     728        43024 :     gimple_catch_set_handler (p, handler);
     729              : 
     730        43036 :   return p;
     731              : }
     732              : 
     733              : /* Build a GIMPLE_EH_FILTER statement.
     734              : 
     735              :    TYPES are the filter's types.
     736              :    FAILURE is the filter's failure action.  */
     737              : 
     738              : geh_filter *
     739         4351 : gimple_build_eh_filter (tree types, gimple_seq failure)
     740              : {
     741         4351 :   geh_filter *p = as_a <geh_filter *> (gimple_alloc (GIMPLE_EH_FILTER, 0));
     742         4351 :   gimple_eh_filter_set_types (p, types);
     743         4351 :   if (failure)
     744         4351 :     gimple_eh_filter_set_failure (p, failure);
     745              : 
     746         4351 :   return p;
     747              : }
     748              : 
     749              : /* Build a GIMPLE_EH_MUST_NOT_THROW statement.  */
     750              : 
     751              : geh_mnt *
     752      1337291 : gimple_build_eh_must_not_throw (tree decl)
     753              : {
     754      1337291 :   geh_mnt *p = as_a <geh_mnt *> (gimple_alloc (GIMPLE_EH_MUST_NOT_THROW, 0));
     755              : 
     756      1337291 :   gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
     757      1337291 :   gcc_assert (flags_from_decl_or_type (decl) & ECF_NORETURN);
     758      1337291 :   gimple_eh_must_not_throw_set_fndecl (p, decl);
     759              : 
     760      1337291 :   return p;
     761              : }
     762              : 
     763              : /* Build a GIMPLE_EH_ELSE statement.  */
     764              : 
     765              : geh_else *
     766          554 : gimple_build_eh_else (gimple_seq n_body, gimple_seq e_body)
     767              : {
     768          554 :   geh_else *p = as_a <geh_else *> (gimple_alloc (GIMPLE_EH_ELSE, 0));
     769          554 :   gimple_eh_else_set_n_body (p, n_body);
     770          554 :   gimple_eh_else_set_e_body (p, e_body);
     771          554 :   return p;
     772              : }
     773              : 
     774              : /* Build a GIMPLE_TRY statement.
     775              : 
     776              :    EVAL is the expression to evaluate.
     777              :    CLEANUP is the cleanup expression.
     778              :    KIND is either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY depending on
     779              :    whether this is a try/catch or a try/finally respectively.  */
     780              : 
     781              : gtry *
     782      3270302 : gimple_build_try (gimple_seq eval, gimple_seq cleanup,
     783              :                   enum gimple_try_flags kind)
     784              : {
     785      3270302 :   gtry *p;
     786              : 
     787      3270302 :   gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
     788      3270302 :   p = as_a <gtry *> (gimple_alloc (GIMPLE_TRY, 0));
     789      3270302 :   gimple_set_subcode (p, kind);
     790      3270302 :   if (eval)
     791      3177524 :     gimple_try_set_eval (p, eval);
     792      3270302 :   if (cleanup)
     793      3270302 :     gimple_try_set_cleanup (p, cleanup);
     794              : 
     795      3270302 :   return p;
     796              : }
     797              : 
     798              : /* Construct a GIMPLE_WITH_CLEANUP_EXPR statement.
     799              : 
     800              :    CLEANUP is the cleanup expression.  */
     801              : 
     802              : gimple *
     803       647777 : gimple_build_wce (gimple_seq cleanup)
     804              : {
     805       647777 :   gimple *p = gimple_alloc (GIMPLE_WITH_CLEANUP_EXPR, 0);
     806       647777 :   if (cleanup)
     807       647777 :     gimple_wce_set_cleanup (p, cleanup);
     808              : 
     809       647777 :   return p;
     810              : }
     811              : 
     812              : 
     813              : /* Build a GIMPLE_RESX statement.  */
     814              : 
     815              : gresx *
     816       944312 : gimple_build_resx (int region)
     817              : {
     818       944312 :   gresx *p
     819       944312 :     = as_a <gresx *> (gimple_build_with_ops (GIMPLE_RESX, ERROR_MARK, 0));
     820       944312 :   p->region = region;
     821       944312 :   return p;
     822              : }
     823              : 
     824              : 
     825              : /* The helper for constructing a gimple switch statement.
     826              :    INDEX is the switch's index.
     827              :    NLABELS is the number of labels in the switch excluding the default.
     828              :    DEFAULT_LABEL is the default label for the switch statement.  */
     829              : 
     830              : gswitch *
     831        71308 : gimple_build_switch_nlabels (unsigned nlabels, tree index, tree default_label)
     832              : {
     833              :   /* nlabels + 1 default label + 1 index.  */
     834        71308 :   gcc_checking_assert (default_label);
     835       142616 :   gswitch *p = as_a <gswitch *> (gimple_build_with_ops (GIMPLE_SWITCH,
     836              :                                                         ERROR_MARK,
     837              :                                                         1 + 1 + nlabels));
     838        71308 :   gimple_switch_set_index (p, index);
     839        71308 :   gimple_switch_set_default_label (p, default_label);
     840        71308 :   return p;
     841              : }
     842              : 
     843              : /* Build a GIMPLE_SWITCH statement.
     844              : 
     845              :    INDEX is the switch's index.
     846              :    DEFAULT_LABEL is the default label
     847              :    ARGS is a vector of labels excluding the default.  */
     848              : 
     849              : gswitch *
     850        71308 : gimple_build_switch (tree index, tree default_label, const vec<tree> &args)
     851              : {
     852        71308 :   unsigned i, nlabels = args.length ();
     853              : 
     854        71308 :   gswitch *p = gimple_build_switch_nlabels (nlabels, index, default_label);
     855              : 
     856              :   /* Copy the labels from the vector to the switch statement.  */
     857      1260213 :   for (i = 0; i < nlabels; i++)
     858      1117597 :     gimple_switch_set_label (p, i + 1, args[i]);
     859              : 
     860        71308 :   return p;
     861              : }
     862              : 
     863              : /* Build a GIMPLE_EH_DISPATCH statement.  */
     864              : 
     865              : geh_dispatch *
     866        44487 : gimple_build_eh_dispatch (int region)
     867              : {
     868        44487 :   geh_dispatch *p
     869        44487 :     = as_a <geh_dispatch *> (
     870              :         gimple_build_with_ops (GIMPLE_EH_DISPATCH, ERROR_MARK, 0));
     871        44487 :   p->region = region;
     872        44487 :   return p;
     873              : }
     874              : 
     875              : /* Build a new GIMPLE_DEBUG_BIND statement.
     876              : 
     877              :    VAR is bound to VALUE; block and location are taken from STMT.  */
     878              : 
     879              : gdebug *
     880     69032587 : gimple_build_debug_bind (tree var, tree value, gimple *stmt MEM_STAT_DECL)
     881              : {
     882     69032587 :   gdebug *p
     883     69032587 :     = as_a <gdebug *> (gimple_build_with_ops_stat (GIMPLE_DEBUG,
     884              :                                                    (unsigned)GIMPLE_DEBUG_BIND, 2
     885              :                                                    PASS_MEM_STAT));
     886     69032587 :   gimple_debug_bind_set_var (p, var);
     887     69032587 :   gimple_debug_bind_set_value (p, value);
     888     69032587 :   if (stmt)
     889     68041089 :     gimple_set_location (p, gimple_location (stmt));
     890              : 
     891     69032587 :   return p;
     892              : }
     893              : 
     894              : 
     895              : /* Build a new GIMPLE_DEBUG_SOURCE_BIND statement.
     896              : 
     897              :    VAR is bound to VALUE; block and location are taken from STMT.  */
     898              : 
     899              : gdebug *
     900       704574 : gimple_build_debug_source_bind (tree var, tree value,
     901              :                                      gimple *stmt MEM_STAT_DECL)
     902              : {
     903       704574 :   gdebug *p
     904       704574 :     = as_a <gdebug *> (
     905              :         gimple_build_with_ops_stat (GIMPLE_DEBUG,
     906              :                                     (unsigned)GIMPLE_DEBUG_SOURCE_BIND, 2
     907              :                                     PASS_MEM_STAT));
     908              : 
     909       704574 :   gimple_debug_source_bind_set_var (p, var);
     910       704574 :   gimple_debug_source_bind_set_value (p, value);
     911       704574 :   if (stmt)
     912       558735 :     gimple_set_location (p, gimple_location (stmt));
     913              : 
     914       704574 :   return p;
     915              : }
     916              : 
     917              : 
     918              : /* Build a new GIMPLE_DEBUG_BEGIN_STMT statement in BLOCK at
     919              :    LOCATION.  */
     920              : 
     921              : gdebug *
     922      2483716 : gimple_build_debug_begin_stmt (tree block, location_t location
     923              :                                     MEM_STAT_DECL)
     924              : {
     925      2483716 :   gdebug *p
     926      2483716 :     = as_a <gdebug *> (
     927              :         gimple_build_with_ops_stat (GIMPLE_DEBUG,
     928              :                                     (unsigned)GIMPLE_DEBUG_BEGIN_STMT, 0
     929              :                                     PASS_MEM_STAT));
     930              : 
     931      2483716 :   gimple_set_location (p, location);
     932      2483716 :   gimple_set_block (p, block);
     933      2483716 :   cfun->debug_marker_count++;
     934              : 
     935      2483716 :   return p;
     936              : }
     937              : 
     938              : 
     939              : /* Build a new GIMPLE_DEBUG_INLINE_ENTRY statement in BLOCK at
     940              :    LOCATION.  The BLOCK links to the inlined function.  */
     941              : 
     942              : gdebug *
     943      4060672 : gimple_build_debug_inline_entry (tree block, location_t location
     944              :                                       MEM_STAT_DECL)
     945              : {
     946      4060672 :   gdebug *p
     947      4060672 :     = as_a <gdebug *> (
     948              :         gimple_build_with_ops_stat (GIMPLE_DEBUG,
     949              :                                     (unsigned)GIMPLE_DEBUG_INLINE_ENTRY, 0
     950              :                                     PASS_MEM_STAT));
     951              : 
     952      4060672 :   gimple_set_location (p, location);
     953      4060672 :   gimple_set_block (p, block);
     954      4060672 :   cfun->debug_marker_count++;
     955              : 
     956      4060672 :   return p;
     957              : }
     958              : 
     959              : 
     960              : /* Build a GIMPLE_OMP_CRITICAL statement.
     961              : 
     962              :    BODY is the sequence of statements for which only one thread can execute.
     963              :    NAME is optional identifier for this critical block.
     964              :    CLAUSES are clauses for this critical block.  */
     965              : 
     966              : gomp_critical *
     967          552 : gimple_build_omp_critical (gimple_seq body, tree name, tree clauses)
     968              : {
     969          552 :   gomp_critical *p
     970          552 :     = as_a <gomp_critical *> (gimple_alloc (GIMPLE_OMP_CRITICAL, 0));
     971          552 :   gimple_omp_critical_set_name (p, name);
     972          552 :   gimple_omp_critical_set_clauses (p, clauses);
     973          552 :   if (body)
     974          457 :     gimple_omp_set_body (p, body);
     975              : 
     976          552 :   return p;
     977              : }
     978              : 
     979              : /* Build a GIMPLE_OMP_FOR statement.
     980              : 
     981              :    BODY is sequence of statements inside the for loop.
     982              :    KIND is the `for' variant.
     983              :    CLAUSES are any of the construct's clauses.
     984              :    COLLAPSE is the collapse count.
     985              :    PRE_BODY is the sequence of statements that are loop invariant.  */
     986              : 
     987              : gomp_for *
     988        56066 : gimple_build_omp_for (gimple_seq body, int kind, tree clauses, size_t collapse,
     989              :                       gimple_seq pre_body)
     990              : {
     991        56066 :   gomp_for *p = as_a <gomp_for *> (gimple_alloc (GIMPLE_OMP_FOR, 0));
     992        56066 :   if (body)
     993        52214 :     gimple_omp_set_body (p, body);
     994        56066 :   gimple_omp_for_set_clauses (p, clauses);
     995        56066 :   gimple_omp_for_set_kind (p, kind);
     996        56066 :   p->collapse = collapse;
     997        56066 :   p->iter =  ggc_cleared_vec_alloc<gimple_omp_for_iter> (collapse);
     998              : 
     999        56066 :   if (pre_body)
    1000         3821 :     gimple_omp_for_set_pre_body (p, pre_body);
    1001              : 
    1002        56066 :   return p;
    1003              : }
    1004              : 
    1005              : 
    1006              : /* Build a GIMPLE_OMP_PARALLEL statement.
    1007              : 
    1008              :    BODY is sequence of statements which are executed in parallel.
    1009              :    CLAUSES are the OMP parallel construct's clauses.
    1010              :    CHILD_FN is the function created for the parallel threads to execute.
    1011              :    DATA_ARG are the shared data argument(s).  */
    1012              : 
    1013              : gomp_parallel *
    1014        19369 : gimple_build_omp_parallel (gimple_seq body, tree clauses, tree child_fn,
    1015              :                            tree data_arg)
    1016              : {
    1017        19369 :   gomp_parallel *p
    1018        19369 :     = as_a <gomp_parallel *> (gimple_alloc (GIMPLE_OMP_PARALLEL, 0));
    1019        19369 :   if (body)
    1020        19176 :     gimple_omp_set_body (p, body);
    1021        19369 :   gimple_omp_parallel_set_clauses (p, clauses);
    1022        19369 :   gimple_omp_parallel_set_child_fn (p, child_fn);
    1023        19369 :   gimple_omp_parallel_set_data_arg (p, data_arg);
    1024              : 
    1025        19369 :   return p;
    1026              : }
    1027              : 
    1028              : 
    1029              : /* Build a GIMPLE_OMP_TASK statement.
    1030              : 
    1031              :    BODY is sequence of statements which are executed by the explicit task.
    1032              :    CLAUSES are the OMP task construct's clauses.
    1033              :    CHILD_FN is the function created for the parallel threads to execute.
    1034              :    DATA_ARG are the shared data argument(s).
    1035              :    COPY_FN is the optional function for firstprivate initialization.
    1036              :    ARG_SIZE and ARG_ALIGN are size and alignment of the data block.  */
    1037              : 
    1038              : gomp_task *
    1039         5715 : gimple_build_omp_task (gimple_seq body, tree clauses, tree child_fn,
    1040              :                        tree data_arg, tree copy_fn, tree arg_size,
    1041              :                        tree arg_align)
    1042              : {
    1043         5715 :   gomp_task *p = as_a <gomp_task *> (gimple_alloc (GIMPLE_OMP_TASK, 0));
    1044         5715 :   if (body)
    1045         5622 :     gimple_omp_set_body (p, body);
    1046         5715 :   gimple_omp_task_set_clauses (p, clauses);
    1047         5715 :   gimple_omp_task_set_child_fn (p, child_fn);
    1048         5715 :   gimple_omp_task_set_data_arg (p, data_arg);
    1049         5715 :   gimple_omp_task_set_copy_fn (p, copy_fn);
    1050         5715 :   gimple_omp_task_set_arg_size (p, arg_size);
    1051         5715 :   gimple_omp_task_set_arg_align (p, arg_align);
    1052              : 
    1053         5715 :   return p;
    1054              : }
    1055              : 
    1056              : 
    1057              : /* Build a GIMPLE_OMP_SECTION statement for a sections statement.
    1058              : 
    1059              :    BODY is the sequence of statements in the section.  */
    1060              : 
    1061              : gimple *
    1062         1279 : gimple_build_omp_section (gimple_seq body)
    1063              : {
    1064         1279 :   gimple *p = gimple_alloc (GIMPLE_OMP_SECTION, 0);
    1065         1279 :   if (body)
    1066         1087 :     gimple_omp_set_body (p, body);
    1067              : 
    1068         1279 :   return p;
    1069              : }
    1070              : 
    1071              : 
    1072              : /* Build a GIMPLE_OMP_STRUCTURED_BLOCK statement.
    1073              : 
    1074              :    BODY is the structured block sequence.  */
    1075              : 
    1076              : gimple *
    1077          791 : gimple_build_omp_structured_block (gimple_seq body)
    1078              : {
    1079          791 :   gimple *p = gimple_alloc (GIMPLE_OMP_STRUCTURED_BLOCK, 0);
    1080          791 :   if (body)
    1081          791 :     gimple_omp_set_body (p, body);
    1082              : 
    1083          791 :   return p;
    1084              : }
    1085              : 
    1086              : 
    1087              : /* Build a GIMPLE_OMP_MASTER statement.
    1088              : 
    1089              :    BODY is the sequence of statements to be executed by just the master.  */
    1090              : 
    1091              : gimple *
    1092          874 : gimple_build_omp_master (gimple_seq body)
    1093              : {
    1094          874 :   gimple *p = gimple_alloc (GIMPLE_OMP_MASTER, 0);
    1095          874 :   if (body)
    1096          793 :     gimple_omp_set_body (p, body);
    1097              : 
    1098          874 :   return p;
    1099              : }
    1100              : 
    1101              : /* Build a GIMPLE_OMP_MASKED statement.
    1102              : 
    1103              :    BODY is the sequence of statements to be executed by the selected thread(s).  */
    1104              : 
    1105              : gimple *
    1106          500 : gimple_build_omp_masked (gimple_seq body, tree clauses)
    1107              : {
    1108          500 :   gimple *p = gimple_alloc (GIMPLE_OMP_MASKED, 0);
    1109          500 :   gimple_omp_masked_set_clauses (p, clauses);
    1110          500 :   if (body)
    1111          420 :     gimple_omp_set_body (p, body);
    1112              : 
    1113          500 :   return p;
    1114              : }
    1115              : 
    1116              : /* Build a GIMPLE_OMP_TASKGROUP statement.
    1117              : 
    1118              :    BODY is the sequence of statements to be executed by the taskgroup
    1119              :    construct.
    1120              :    CLAUSES are any of the construct's clauses.  */
    1121              : 
    1122              : gimple *
    1123          611 : gimple_build_omp_taskgroup (gimple_seq body, tree clauses)
    1124              : {
    1125          611 :   gimple *p = gimple_alloc (GIMPLE_OMP_TASKGROUP, 0);
    1126          611 :   gimple_omp_taskgroup_set_clauses (p, clauses);
    1127          611 :   if (body)
    1128          611 :     gimple_omp_set_body (p, body);
    1129              : 
    1130          611 :   return p;
    1131              : }
    1132              : 
    1133              : 
    1134              : /* Build a GIMPLE_OMP_CONTINUE statement.
    1135              : 
    1136              :    CONTROL_DEF is the definition of the control variable.
    1137              :    CONTROL_USE is the use of the control variable.  */
    1138              : 
    1139              : gomp_continue *
    1140        54483 : gimple_build_omp_continue (tree control_def, tree control_use)
    1141              : {
    1142        54483 :   gomp_continue *p
    1143        54483 :     = as_a <gomp_continue *> (gimple_alloc (GIMPLE_OMP_CONTINUE, 0));
    1144        54483 :   gimple_omp_continue_set_control_def (p, control_def);
    1145        54483 :   gimple_omp_continue_set_control_use (p, control_use);
    1146        54483 :   return p;
    1147              : }
    1148              : 
    1149              : /* Build a GIMPLE_OMP_ORDERED statement.
    1150              : 
    1151              :    BODY is the sequence of statements inside a loop that will executed in
    1152              :    sequence.
    1153              :    CLAUSES are clauses for this statement.  */
    1154              : 
    1155              : gomp_ordered *
    1156         1852 : gimple_build_omp_ordered (gimple_seq body, tree clauses)
    1157              : {
    1158         1852 :   gomp_ordered *p
    1159         1852 :     = as_a <gomp_ordered *> (gimple_alloc (GIMPLE_OMP_ORDERED, 0));
    1160         1852 :   gimple_omp_ordered_set_clauses (p, clauses);
    1161         1852 :   if (body)
    1162          501 :     gimple_omp_set_body (p, body);
    1163              : 
    1164         1852 :   return p;
    1165              : }
    1166              : 
    1167              : 
    1168              : /* Build a GIMPLE_OMP_RETURN statement.
    1169              :    WAIT_P is true if this is a non-waiting return.  */
    1170              : 
    1171              : gimple *
    1172       107102 : gimple_build_omp_return (bool wait_p)
    1173              : {
    1174       107102 :   gimple *p = gimple_alloc (GIMPLE_OMP_RETURN, 0);
    1175       107102 :   if (wait_p)
    1176        40866 :     gimple_omp_return_set_nowait (p);
    1177              : 
    1178       107102 :   return p;
    1179              : }
    1180              : 
    1181              : 
    1182              : /* Build a GIMPLE_OMP_SCAN statement.
    1183              : 
    1184              :    BODY is the sequence of statements to be executed by the scan
    1185              :    construct.
    1186              :    CLAUSES are any of the construct's clauses.  */
    1187              : 
    1188              : gomp_scan *
    1189         1332 : gimple_build_omp_scan (gimple_seq body, tree clauses)
    1190              : {
    1191         1332 :   gomp_scan *p
    1192         1332 :     = as_a <gomp_scan *> (gimple_alloc (GIMPLE_OMP_SCAN, 0));
    1193         1332 :   gimple_omp_scan_set_clauses (p, clauses);
    1194         1332 :   if (body)
    1195         1098 :     gimple_omp_set_body (p, body);
    1196              : 
    1197         1332 :   return p;
    1198              : }
    1199              : 
    1200              : 
    1201              : /* Build a GIMPLE_OMP_SECTIONS statement.
    1202              : 
    1203              :    BODY is a sequence of section statements.
    1204              :    CLAUSES are any of the OMP sections contsruct's clauses: private,
    1205              :    firstprivate, lastprivate, reduction, and nowait.  */
    1206              : 
    1207              : gomp_sections *
    1208          634 : gimple_build_omp_sections (gimple_seq body, tree clauses)
    1209              : {
    1210          634 :   gomp_sections *p
    1211          634 :     = as_a <gomp_sections *> (gimple_alloc (GIMPLE_OMP_SECTIONS, 0));
    1212          634 :   if (body)
    1213          634 :     gimple_omp_set_body (p, body);
    1214          634 :   gimple_omp_sections_set_clauses (p, clauses);
    1215              : 
    1216          634 :   return p;
    1217              : }
    1218              : 
    1219              : 
    1220              : /* Build a GIMPLE_OMP_SECTIONS_SWITCH.  */
    1221              : 
    1222              : gimple *
    1223          386 : gimple_build_omp_sections_switch (void)
    1224              : {
    1225          386 :   return gimple_alloc (GIMPLE_OMP_SECTIONS_SWITCH, 0);
    1226              : }
    1227              : 
    1228              : 
    1229              : /* Build a GIMPLE_OMP_SINGLE statement.
    1230              : 
    1231              :    BODY is the sequence of statements that will be executed once.
    1232              :    CLAUSES are any of the OMP single construct's clauses: private, firstprivate,
    1233              :    copyprivate, nowait.  */
    1234              : 
    1235              : gomp_single *
    1236         1305 : gimple_build_omp_single (gimple_seq body, tree clauses)
    1237              : {
    1238         1305 :   gomp_single *p
    1239         1305 :     = as_a <gomp_single *> (gimple_alloc (GIMPLE_OMP_SINGLE, 0));
    1240         1305 :   if (body)
    1241         1192 :     gimple_omp_set_body (p, body);
    1242         1305 :   gimple_omp_single_set_clauses (p, clauses);
    1243              : 
    1244         1305 :   return p;
    1245              : }
    1246              : 
    1247              : 
    1248              : /* Build a GIMPLE_OMP_SCOPE statement.
    1249              : 
    1250              :    BODY is the sequence of statements that will be executed once.
    1251              :    CLAUSES are any of the OMP scope construct's clauses: private, reduction,
    1252              :    nowait.  */
    1253              : 
    1254              : gimple *
    1255          242 : gimple_build_omp_scope (gimple_seq body, tree clauses)
    1256              : {
    1257          242 :   gimple *p = gimple_alloc (GIMPLE_OMP_SCOPE, 0);
    1258          242 :   gimple_omp_scope_set_clauses (p, clauses);
    1259          242 :   if (body)
    1260          168 :     gimple_omp_set_body (p, body);
    1261              : 
    1262          242 :   return p;
    1263              : }
    1264              : 
    1265              : /* Build a GIMPLE_OMP_DISPATCH statement.
    1266              : 
    1267              :    BODY is the target function call to be dispatched.
    1268              :    CLAUSES are any of the OMP dispatch construct's clauses.  */
    1269              : 
    1270              : gimple *
    1271          852 : gimple_build_omp_dispatch (gimple_seq body, tree clauses)
    1272              : {
    1273          852 :   gimple *p = gimple_alloc (GIMPLE_OMP_DISPATCH, 0);
    1274          852 :   gimple_omp_dispatch_set_clauses (p, clauses);
    1275          852 :   if (body)
    1276          852 :     gimple_omp_set_body (p, body);
    1277              : 
    1278          852 :   return p;
    1279              : }
    1280              : 
    1281              : /* Build a GIMPLE_OMP_INTEROP statement.
    1282              : 
    1283              :    CLAUSES are any of the OMP interop construct's clauses.  */
    1284              : 
    1285              : gimple *
    1286          612 : gimple_build_omp_interop (tree clauses)
    1287              : {
    1288          612 :   gimple *p = gimple_alloc (GIMPLE_OMP_INTEROP, 0);
    1289          612 :   gimple_omp_interop_set_clauses (p, clauses);
    1290              : 
    1291          612 :   return p;
    1292              : }
    1293              : 
    1294              : /* Build a GIMPLE_OMP_TARGET statement.
    1295              : 
    1296              :    BODY is the sequence of statements that will be executed.
    1297              :    KIND is the kind of the region.
    1298              :    CLAUSES are any of the construct's clauses.
    1299              :    ITERATOR_LOOPS is an optional sequence containing constructed loops
    1300              :    for OpenMP iterators.  */
    1301              : 
    1302              : gomp_target *
    1303        44606 : gimple_build_omp_target (gimple_seq body, int kind, tree clauses,
    1304              :                          gimple_seq iterator_loops)
    1305              : {
    1306        44606 :   gomp_target *p
    1307        44606 :     = as_a <gomp_target *> (gimple_alloc (GIMPLE_OMP_TARGET, 0));
    1308        44606 :   if (body)
    1309        30415 :     gimple_omp_set_body (p, body);
    1310        44606 :   gimple_omp_target_set_clauses (p, clauses);
    1311        44606 :   gimple_omp_target_set_kind (p, kind);
    1312        44606 :   gimple_omp_target_set_iterator_loops (p, iterator_loops);
    1313              : 
    1314        44606 :   return p;
    1315              : }
    1316              : 
    1317              : 
    1318              : /* Build a GIMPLE_OMP_TEAMS statement.
    1319              : 
    1320              :    BODY is the sequence of statements that will be executed.
    1321              :    CLAUSES are any of the OMP teams construct's clauses.  */
    1322              : 
    1323              : gomp_teams *
    1324         9556 : gimple_build_omp_teams (gimple_seq body, tree clauses)
    1325              : {
    1326         9556 :   gomp_teams *p = as_a <gomp_teams *> (gimple_alloc (GIMPLE_OMP_TEAMS, 0));
    1327         9556 :   if (body)
    1328         9556 :     gimple_omp_set_body (p, body);
    1329         9556 :   gimple_omp_teams_set_clauses (p, clauses);
    1330              : 
    1331         9556 :   return p;
    1332              : }
    1333              : 
    1334              : 
    1335              : /* Build a GIMPLE_OMP_ATOMIC_LOAD statement.  */
    1336              : 
    1337              : gomp_atomic_load *
    1338        10811 : gimple_build_omp_atomic_load (tree lhs, tree rhs, enum omp_memory_order mo)
    1339              : {
    1340        10811 :   gomp_atomic_load *p
    1341        10811 :     = as_a <gomp_atomic_load *> (gimple_alloc (GIMPLE_OMP_ATOMIC_LOAD, 0));
    1342        10811 :   gimple_omp_atomic_load_set_lhs (p, lhs);
    1343        10811 :   gimple_omp_atomic_load_set_rhs (p, rhs);
    1344        10811 :   gimple_omp_atomic_set_memory_order (p, mo);
    1345        10811 :   return p;
    1346              : }
    1347              : 
    1348              : /* Build a GIMPLE_OMP_ATOMIC_STORE statement.
    1349              : 
    1350              :    VAL is the value we are storing.  */
    1351              : 
    1352              : gomp_atomic_store *
    1353        10811 : gimple_build_omp_atomic_store (tree val, enum omp_memory_order mo)
    1354              : {
    1355        10811 :   gomp_atomic_store *p
    1356        10811 :     = as_a <gomp_atomic_store *> (gimple_alloc (GIMPLE_OMP_ATOMIC_STORE, 0));
    1357        10811 :   gimple_omp_atomic_store_set_val (p, val);
    1358        10811 :   gimple_omp_atomic_set_memory_order (p, mo);
    1359        10811 :   return p;
    1360              : }
    1361              : 
    1362              : /* Build a GIMPLE_ASSUME statement.  */
    1363              : 
    1364              : gimple *
    1365          204 : gimple_build_assume (tree guard, gimple_seq body)
    1366              : {
    1367          204 :   gimple_statement_assume *p
    1368          204 :     = as_a <gimple_statement_assume *> (gimple_alloc (GIMPLE_ASSUME, 0));
    1369          204 :   gimple_assume_set_guard (p, guard);
    1370          204 :   *gimple_assume_body_ptr (p) = body;
    1371          204 :   return p;
    1372              : }
    1373              : 
    1374              : /* Build a GIMPLE_TRANSACTION statement.  */
    1375              : 
    1376              : gtransaction *
    1377          545 : gimple_build_transaction (gimple_seq body)
    1378              : {
    1379          545 :   gtransaction *p
    1380          545 :     = as_a <gtransaction *> (gimple_alloc (GIMPLE_TRANSACTION, 0));
    1381          545 :   gimple_transaction_set_body (p, body);
    1382          545 :   gimple_transaction_set_label_norm (p, 0);
    1383          545 :   gimple_transaction_set_label_uninst (p, 0);
    1384          545 :   gimple_transaction_set_label_over (p, 0);
    1385          545 :   return p;
    1386              : }
    1387              : 
    1388              : #if defined ENABLE_GIMPLE_CHECKING
    1389              : /* Complain of a gimple type mismatch and die.  */
    1390              : 
    1391              : void
    1392            0 : gimple_check_failed (const gimple *gs, const char *file, int line,
    1393              :                      const char *function, enum gimple_code code,
    1394              :                      enum tree_code subcode)
    1395              : {
    1396            0 :   internal_error ("gimple check: expected %s(%s), have %s(%s) in %s, at %s:%d",
    1397            0 :                   gimple_code_name[code],
    1398              :                   get_tree_code_name (subcode),
    1399            0 :                   gimple_code_name[gimple_code (gs)],
    1400            0 :                   gs->subcode > 0
    1401            0 :                     ? get_tree_code_name ((enum tree_code) gs->subcode)
    1402              :                     : "",
    1403              :                   function, trim_filename (file), line);
    1404              : }
    1405              : #endif /* ENABLE_GIMPLE_CHECKING */
    1406              : 
    1407              : 
    1408              : /* Link gimple statement GS to the end of the sequence *SEQ_P.  If
    1409              :    *SEQ_P is NULL, a new sequence is allocated.  */
    1410              : 
    1411              : void
    1412     47939549 : gimple_seq_add_stmt (gimple_seq *seq_p, gimple *gs)
    1413              : {
    1414     47939549 :   gimple_stmt_iterator si;
    1415     47939549 :   if (gs == NULL)
    1416            0 :     return;
    1417              : 
    1418     47939549 :   si = gsi_last (*seq_p);
    1419     47939549 :   gsi_insert_after (&si, gs, GSI_NEW_STMT);
    1420              : }
    1421              : 
    1422              : /* Link gimple statement GS to the end of the sequence *SEQ_P.  If
    1423              :    *SEQ_P is NULL, a new sequence is allocated.  This function is
    1424              :    similar to gimple_seq_add_stmt, but does not scan the operands.
    1425              :    During gimplification, we need to manipulate statement sequences
    1426              :    before the def/use vectors have been constructed.  */
    1427              : 
    1428              : void
    1429    197119690 : gimple_seq_add_stmt_without_update (gimple_seq *seq_p, gimple *gs)
    1430              : {
    1431    197119690 :   gimple_stmt_iterator si;
    1432              : 
    1433    197119690 :   if (gs == NULL)
    1434            0 :     return;
    1435              : 
    1436    197119690 :   si = gsi_last (*seq_p);
    1437    197119690 :   gsi_insert_after_without_update (&si, gs, GSI_NEW_STMT);
    1438              : }
    1439              : 
    1440              : /* Append sequence SRC to the end of sequence *DST_P.  If *DST_P is
    1441              :    NULL, a new sequence is allocated.  */
    1442              : 
    1443              : void
    1444     17392367 : gimple_seq_add_seq (gimple_seq *dst_p, gimple_seq src)
    1445              : {
    1446     17392367 :   gimple_stmt_iterator si;
    1447     17392367 :   if (src == NULL)
    1448      5409319 :     return;
    1449              : 
    1450     11983048 :   si = gsi_last (*dst_p);
    1451     11983048 :   gsi_insert_seq_after (&si, src, GSI_NEW_STMT);
    1452              : }
    1453              : 
    1454              : /* Append sequence SRC to the end of sequence *DST_P.  If *DST_P is
    1455              :    NULL, a new sequence is allocated.  This function is
    1456              :    similar to gimple_seq_add_seq, but does not scan the operands.  */
    1457              : 
    1458              : void
    1459       279827 : gimple_seq_add_seq_without_update (gimple_seq *dst_p, gimple_seq src)
    1460              : {
    1461       279827 :   gimple_stmt_iterator si;
    1462       279827 :   if (src == NULL)
    1463       100615 :     return;
    1464              : 
    1465       179212 :   si = gsi_last (*dst_p);
    1466       179212 :   gsi_insert_seq_after_without_update (&si, src, GSI_NEW_STMT);
    1467              : }
    1468              : 
    1469              : /* Determine whether to assign a location to the statement GS.  */
    1470              : 
    1471              : static bool
    1472    268662013 : should_carry_location_p (gimple *gs)
    1473              : {
    1474              :   /* Don't emit a line note for a label.  We particularly don't want to
    1475              :      emit one for the break label, since it doesn't actually correspond
    1476              :      to the beginning of the loop/switch.  */
    1477    268662013 :   if (gimple_code (gs) == GIMPLE_LABEL)
    1478            0 :     return false;
    1479              : 
    1480              :   return true;
    1481              : }
    1482              : 
    1483              : /* Set the location for gimple statement GS to LOCATION.  */
    1484              : 
    1485              : static void
    1486    683069937 : annotate_one_with_location (gimple *gs, location_t location)
    1487              : {
    1488    683069937 :   if (!gimple_has_location (gs)
    1489    338332695 :       && !gimple_do_not_emit_location_p (gs)
    1490    683069937 :       && should_carry_location_p (gs))
    1491     26424054 :     gimple_set_location (gs, location);
    1492    683069937 : }
    1493              : 
    1494              : /* Set LOCATION for all the statements after iterator GSI in sequence
    1495              :    SEQ.  If GSI is pointing to the end of the sequence, start with the
    1496              :    first statement in SEQ.  */
    1497              : 
    1498              : void
    1499    101553288 : annotate_all_with_location_after (gimple_seq seq, gimple_stmt_iterator gsi,
    1500              :                                   location_t location)
    1501              : {
    1502    101553288 :   if (gsi_end_p (gsi))
    1503    101553288 :     gsi = gsi_start (seq);
    1504              :   else
    1505     66635411 :     gsi_next (&gsi);
    1506              : 
    1507    784296311 :   for (; !gsi_end_p (gsi); gsi_next (&gsi))
    1508    682743023 :     annotate_one_with_location (gsi_stmt (gsi), location);
    1509    101553288 : }
    1510              : 
    1511              : /* Set the location for all the statements in a sequence STMT_P to LOCATION.  */
    1512              : 
    1513              : void
    1514       224825 : annotate_all_with_location (gimple_seq stmt_p, location_t location)
    1515              : {
    1516       224825 :   gimple_stmt_iterator i;
    1517              : 
    1518       224825 :   if (gimple_seq_empty_p (stmt_p))
    1519       224825 :     return;
    1520              : 
    1521       542138 :   for (i = gsi_start (stmt_p); !gsi_end_p (i); gsi_next (&i))
    1522              :     {
    1523       326914 :       gimple *gs = gsi_stmt (i);
    1524       326914 :       annotate_one_with_location (gs, location);
    1525              :     }
    1526              : }
    1527              : 
    1528              : /* Helper function of empty_body_p.  Return true if STMT is an empty
    1529              :    statement.  */
    1530              : 
    1531              : static bool
    1532        38440 : empty_stmt_p (gimple *stmt)
    1533              : {
    1534        38440 :   if (gimple_code (stmt) == GIMPLE_NOP)
    1535              :     return true;
    1536        38438 :   if (gbind *bind_stmt = dyn_cast <gbind *> (stmt))
    1537        22694 :     return empty_body_p (gimple_bind_body (bind_stmt));
    1538              :   return false;
    1539              : }
    1540              : 
    1541              : 
    1542              : /* Return true if BODY contains nothing but empty statements.  */
    1543              : 
    1544              : bool
    1545        38519 : empty_body_p (gimple_seq body)
    1546              : {
    1547        38519 :   gimple_stmt_iterator i;
    1548              : 
    1549        38519 :   if (gimple_seq_empty_p (body))
    1550              :     return true;
    1551        38627 :   for (i = gsi_start (body); !gsi_end_p (i); gsi_next (&i))
    1552        38440 :     if (!empty_stmt_p (gsi_stmt (i))
    1553        38440 :         && !is_gimple_debug (gsi_stmt (i)))
    1554              :       return false;
    1555              : 
    1556              :   return true;
    1557              : }
    1558              : 
    1559              : 
    1560              : /* Perform a deep copy of sequence SRC and return the result.  */
    1561              : 
    1562              : gimple_seq
    1563      1880931 : gimple_seq_copy (gimple_seq src)
    1564              : {
    1565      1880931 :   gimple_stmt_iterator gsi;
    1566      1880931 :   gimple_seq new_seq = NULL;
    1567      1880931 :   gimple *stmt;
    1568              : 
    1569      4229644 :   for (gsi = gsi_start (src); !gsi_end_p (gsi); gsi_next (&gsi))
    1570              :     {
    1571      2348713 :       stmt = gimple_copy (gsi_stmt (gsi));
    1572      2348713 :       gimple_seq_add_stmt (&new_seq, stmt);
    1573              :     }
    1574              : 
    1575      1880931 :   return new_seq;
    1576              : }
    1577              : 
    1578              : 
    1579              : 
    1580              : /* Return true if calls C1 and C2 are known to go to the same function.  */
    1581              : 
    1582              : bool
    1583      1007890 : gimple_call_same_target_p (const gimple *c1, const gimple *c2)
    1584              : {
    1585      1007890 :   if (gimple_call_internal_p (c1))
    1586         8290 :     return (gimple_call_internal_p (c2)
    1587         8290 :             && gimple_call_internal_fn (c1) == gimple_call_internal_fn (c2)
    1588        16580 :             && (!gimple_call_internal_unique_p (as_a <const gcall *> (c1))
    1589            0 :                 || c1 == c2));
    1590              :   else
    1591       999600 :     return (gimple_call_fn (c1) == gimple_call_fn (c2)
    1592       999600 :             || (gimple_call_fndecl (c1)
    1593       998971 :                 && gimple_call_fndecl (c1) == gimple_call_fndecl (c2)));
    1594              : }
    1595              : 
    1596              : /* Detect flags from a GIMPLE_CALL.  This is just like
    1597              :    call_expr_flags, but for gimple tuples.  */
    1598              : 
    1599              : int
    1600   4386677468 : gimple_call_flags (const gimple *stmt)
    1601              : {
    1602   4386677468 :   int flags = 0;
    1603              : 
    1604   4386677468 :   if (gimple_call_internal_p (stmt))
    1605    127401896 :     flags = internal_fn_flags (gimple_call_internal_fn (stmt));
    1606              :   else
    1607              :     {
    1608   4259275572 :       tree decl = gimple_call_fndecl (stmt);
    1609   4259275572 :       if (decl)
    1610   4133224556 :         flags = flags_from_decl_or_type (decl);
    1611   4259275572 :       flags |= flags_from_decl_or_type (gimple_call_fntype (stmt));
    1612              :     }
    1613              : 
    1614   4386677468 :   if (stmt->subcode & GF_CALL_NOTHROW)
    1615    756568394 :     flags |= ECF_NOTHROW;
    1616   4386677468 :   if (stmt->subcode & GF_CALL_XTHROW)
    1617     17065975 :     flags |= ECF_XTHROW;
    1618              : 
    1619   4386677468 :   if (stmt->subcode & GF_CALL_BY_DESCRIPTOR)
    1620            0 :     flags |= ECF_BY_DESCRIPTOR;
    1621              : 
    1622   4386677468 :   return flags;
    1623              : }
    1624              : 
    1625              : /* Return the "fn spec" string for call STMT.  */
    1626              : 
    1627              : attr_fnspec
    1628    459446005 : gimple_call_fnspec (const gcall *stmt)
    1629              : {
    1630    459446005 :   tree type, attr;
    1631              : 
    1632    459446005 :   if (gimple_call_internal_p (stmt))
    1633              :     {
    1634     10232686 :       const_tree spec = internal_fn_fnspec (gimple_call_internal_fn (stmt));
    1635     10232686 :       if (spec)
    1636       481820 :         return spec;
    1637              :       else
    1638      9750866 :         return "";
    1639              :     }
    1640              : 
    1641    449213319 :   type = gimple_call_fntype (stmt);
    1642    449213319 :   if (type)
    1643              :     {
    1644    449213319 :       attr = lookup_attribute ("fn spec", TYPE_ATTRIBUTES (type));
    1645    449213319 :       if (attr)
    1646     63293508 :         return TREE_VALUE (TREE_VALUE (attr));
    1647              :     }
    1648    385919811 :   if (gimple_call_builtin_p (stmt, BUILT_IN_NORMAL))
    1649    118615606 :     return builtin_fnspec (gimple_call_fndecl (stmt));
    1650    267304205 :   tree fndecl = gimple_call_fndecl (stmt);
    1651              :   /* If the call is to a replaceable operator delete and results
    1652              :      from a delete expression as opposed to a direct call to
    1653              :      such operator, then we can treat it as free.  */
    1654    267304205 :   if (fndecl
    1655    252959810 :       && DECL_IS_OPERATOR_DELETE_P (fndecl)
    1656      7122813 :       && DECL_IS_REPLACEABLE_OPERATOR (fndecl)
    1657    274421155 :       && gimple_call_from_new_or_delete (stmt))
    1658              :     {
    1659      7063090 :       if (flag_assume_sane_operators_new_delete)
    1660      7061604 :         return ".co ";
    1661              :       else
    1662         1486 :         return ". o ";
    1663              :     }
    1664              :   /* Similarly operator new can be treated as malloc.  */
    1665    260241115 :   if (fndecl
    1666    245896720 :       && DECL_IS_REPLACEABLE_OPERATOR_NEW_P (fndecl)
    1667    263355030 :       && gimple_call_from_new_or_delete (stmt))
    1668              :     {
    1669      3080520 :       if (flag_assume_sane_operators_new_delete)
    1670      3079527 :         return "mC";
    1671              :       else
    1672          993 :         return "m ";
    1673              :     }
    1674    257160595 :   return "";
    1675              : }
    1676              : 
    1677              : /* Detects argument flags for argument number ARG on call STMT.  */
    1678              : 
    1679              : int
    1680    126907664 : gimple_call_arg_flags (const gcall *stmt, unsigned arg)
    1681              : {
    1682    126907664 :   attr_fnspec fnspec = gimple_call_fnspec (stmt);
    1683    126907664 :   int flags = 0;
    1684              : 
    1685    126907664 :   if (fnspec.known_p ())
    1686     25465142 :     flags = fnspec.arg_eaf_flags (arg);
    1687    126907664 :   tree callee = gimple_call_fndecl (stmt);
    1688    126907664 :   if (callee)
    1689              :     {
    1690    118699033 :       cgraph_node *node = cgraph_node::get (callee);
    1691    118699033 :       modref_summary *summary = node ? get_modref_function_summary (node)
    1692              :                                 : NULL;
    1693              : 
    1694    118463889 :       if (summary && summary->arg_flags.length () > arg)
    1695              :         {
    1696     24012822 :           int modref_flags = summary->arg_flags[arg];
    1697              : 
    1698              :           /* We have possibly optimized out load.  Be conservative here.  */
    1699     24012822 :           if (!node->binds_to_current_def_p ())
    1700     11652160 :             modref_flags = interposable_eaf_flags (modref_flags, flags);
    1701     24012822 :           if (dbg_cnt (ipa_mod_ref_pta))
    1702     24012822 :             flags |= modref_flags;
    1703              :         }
    1704              :     }
    1705    126907664 :   return flags;
    1706              : }
    1707              : 
    1708              : /* Detects argument flags for return slot on call STMT.  */
    1709              : 
    1710              : int
    1711       101083 : gimple_call_retslot_flags (const gcall *stmt)
    1712              : {
    1713       101083 :   int flags = implicit_retslot_eaf_flags;
    1714              : 
    1715       101083 :   tree callee = gimple_call_fndecl (stmt);
    1716       101083 :   if (callee)
    1717              :     {
    1718        92319 :       cgraph_node *node = cgraph_node::get (callee);
    1719        92319 :       modref_summary *summary = node ? get_modref_function_summary (node)
    1720              :                                 : NULL;
    1721              : 
    1722        92319 :       if (summary)
    1723              :         {
    1724        65221 :           int modref_flags = summary->retslot_flags;
    1725              : 
    1726              :           /* We have possibly optimized out load.  Be conservative here.  */
    1727        65221 :           if (!node->binds_to_current_def_p ())
    1728        54891 :             modref_flags = interposable_eaf_flags (modref_flags, flags);
    1729        65221 :           if (dbg_cnt (ipa_mod_ref_pta))
    1730        65221 :             flags |= modref_flags;
    1731              :         }
    1732              :     }
    1733       101083 :   return flags;
    1734              : }
    1735              : 
    1736              : /* Detects argument flags for static chain on call STMT.  */
    1737              : 
    1738              : int
    1739       181133 : gimple_call_static_chain_flags (const gcall *stmt)
    1740              : {
    1741       181133 :   int flags = 0;
    1742              : 
    1743       181133 :   tree callee = gimple_call_fndecl (stmt);
    1744       181133 :   if (callee)
    1745              :     {
    1746        28354 :       cgraph_node *node = cgraph_node::get (callee);
    1747        28354 :       modref_summary *summary = node ? get_modref_function_summary (node)
    1748              :                                 : NULL;
    1749              : 
    1750              :       /* Nested functions should always bind to current def since
    1751              :          there is no public ABI for them.  */
    1752        28354 :       gcc_checking_assert (node->binds_to_current_def_p ());
    1753        28354 :       if (summary)
    1754              :         {
    1755        26491 :           int modref_flags = summary->static_chain_flags;
    1756              : 
    1757        26491 :           if (dbg_cnt (ipa_mod_ref_pta))
    1758       181133 :             flags |= modref_flags;
    1759              :         }
    1760              :     }
    1761       181133 :   return flags;
    1762              : }
    1763              : 
    1764              : /* Detects return flags for the call STMT.  */
    1765              : 
    1766              : int
    1767     52416066 : gimple_call_return_flags (const gcall *stmt)
    1768              : {
    1769     52416066 :   if (gimple_call_flags (stmt) & ECF_MALLOC)
    1770              :     return ERF_NOALIAS;
    1771              : 
    1772     50320617 :   attr_fnspec fnspec = gimple_call_fnspec (stmt);
    1773              : 
    1774     50320617 :   unsigned int arg_no;
    1775     50320617 :   if (fnspec.returns_arg (&arg_no))
    1776      1264960 :     return ERF_RETURNS_ARG | arg_no;
    1777              : 
    1778     49055657 :   if (fnspec.returns_noalias_p ())
    1779         6076 :     return ERF_NOALIAS;
    1780              :   return 0;
    1781              : }
    1782              : 
    1783              : 
    1784              : /* Return true if call STMT is known to return a non-zero result.  */
    1785              : 
    1786              : bool
    1787     13440222 : gimple_call_nonnull_result_p (const gcall *call)
    1788              : {
    1789     13440222 :   tree fndecl = gimple_call_fndecl (call);
    1790     13440222 :   if (!fndecl)
    1791              :     return false;
    1792     12249038 :   if (flag_delete_null_pointer_checks && !flag_check_new
    1793     12248983 :       && DECL_IS_OPERATOR_NEW_P (fndecl)
    1794     12782089 :       && !TREE_NOTHROW (fndecl))
    1795              :     return true;
    1796              : 
    1797              :   /* References are always non-NULL.  */
    1798     11731719 :   if (flag_delete_null_pointer_checks
    1799     11731719 :       && TREE_CODE (TREE_TYPE (fndecl)) == REFERENCE_TYPE)
    1800              :     return true;
    1801              : 
    1802     11731719 :   if (flag_delete_null_pointer_checks
    1803     23457063 :       && lookup_attribute ("returns_nonnull",
    1804     11725344 :                            TYPE_ATTRIBUTES (gimple_call_fntype (call))))
    1805              :     return true;
    1806     11673729 :   return gimple_alloca_call_p (call);
    1807              : }
    1808              : 
    1809              : 
    1810              : /* If CALL returns a non-null result in an argument, return that arg.  */
    1811              : 
    1812              : tree
    1813     12797369 : gimple_call_nonnull_arg (const gcall *call)
    1814              : {
    1815     12797369 :   tree fndecl = gimple_call_fndecl (call);
    1816     12797369 :   if (!fndecl)
    1817              :     return NULL_TREE;
    1818              : 
    1819     11612560 :   unsigned rf = gimple_call_return_flags (call);
    1820     11612560 :   if (rf & ERF_RETURNS_ARG)
    1821              :     {
    1822            0 :       unsigned argnum = rf & ERF_RETURN_ARG_MASK;
    1823            0 :       if (argnum < gimple_call_num_args (call))
    1824              :         {
    1825            0 :           tree arg = gimple_call_arg (call, argnum);
    1826            0 :           if (SSA_VAR_P (arg)
    1827            0 :               && infer_nonnull_range_by_attribute (call, arg))
    1828            0 :             return arg;
    1829              :         }
    1830              :     }
    1831              :   return NULL_TREE;
    1832              : }
    1833              : 
    1834              : 
    1835              : /* Return true if GS is a copy assignment.  */
    1836              : 
    1837              : bool
    1838    206307544 : gimple_assign_copy_p (const gimple *gs)
    1839              : {
    1840    206307544 :   return (gimple_assign_single_p (gs)
    1841    206307544 :           && is_gimple_val (gimple_op (gs, 1)));
    1842              : }
    1843              : 
    1844              : 
    1845              : /* Return true if GS is a SSA_NAME copy assignment.  */
    1846              : 
    1847              : bool
    1848     41503571 : gimple_assign_ssa_name_copy_p (const gimple *gs)
    1849              : {
    1850     41503571 :   return (gimple_assign_single_p (gs)
    1851     23466099 :           && TREE_CODE (gimple_assign_lhs (gs)) == SSA_NAME
    1852     55091774 :           && TREE_CODE (gimple_assign_rhs1 (gs)) == SSA_NAME);
    1853              : }
    1854              : 
    1855              : 
    1856              : /* Return true if GS is an assignment with a unary RHS, but the
    1857              :    operator has no effect on the assigned value.  The logic is adapted
    1858              :    from STRIP_NOPS.  This predicate is intended to be used in tuplifying
    1859              :    instances in which STRIP_NOPS was previously applied to the RHS of
    1860              :    an assignment.
    1861              : 
    1862              :    NOTE: In the use cases that led to the creation of this function
    1863              :    and of gimple_assign_single_p, it is typical to test for either
    1864              :    condition and to proceed in the same manner.  In each case, the
    1865              :    assigned value is represented by the single RHS operand of the
    1866              :    assignment.  I suspect there may be cases where gimple_assign_copy_p,
    1867              :    gimple_assign_single_p, or equivalent logic is used where a similar
    1868              :    treatment of unary NOPs is appropriate.  */
    1869              : 
    1870              : bool
    1871        46407 : gimple_assign_unary_nop_p (const gimple *gs)
    1872              : {
    1873        46407 :   auto as = dyn_cast<const gassign *> (gs);
    1874        46407 :   return (as
    1875        46407 :           && (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (as))
    1876        40937 :               || gimple_assign_rhs_code (as) == NON_LVALUE_EXPR)
    1877         5470 :           && gimple_assign_rhs1 (as) != error_mark_node
    1878        10940 :           && (TYPE_MODE (TREE_TYPE (gimple_assign_lhs (as)))
    1879         5470 :               == TYPE_MODE (TREE_TYPE (gimple_assign_rhs1 (as)))));
    1880              : }
    1881              : 
    1882              : /* Return true if GS is an assignment that loads from its rhs1.  */
    1883              : 
    1884              : bool
    1885    560562439 : gimple_assign_load_p (const gimple *gs)
    1886              : {
    1887    560562439 :   tree rhs;
    1888    560562439 :   if (!gimple_assign_single_p (gs))
    1889              :     return false;
    1890    339086093 :   rhs = gimple_assign_rhs1 (gs);
    1891    339086093 :   if (TREE_CODE (rhs) == WITH_SIZE_EXPR)
    1892              :     return true;
    1893    339086089 :   if (handled_component_p (rhs))
    1894     92076987 :     rhs = TREE_OPERAND (rhs, 0);
    1895    339086089 :   return (handled_component_p (rhs)
    1896    312988607 :           || DECL_P (rhs)
    1897    253431152 :           || TREE_CODE (rhs) == MEM_REF
    1898    187501572 :           || TREE_CODE (rhs) == TARGET_MEM_REF);
    1899              : }
    1900              : 
    1901              : 
    1902              : /* Set BB to be the basic block holding G.  */
    1903              : 
    1904              : void
    1905    754571171 : gimple_set_bb (gimple *stmt, basic_block bb)
    1906              : {
    1907    754571171 :   stmt->bb = bb;
    1908              : 
    1909    754571171 :   if (gimple_code (stmt) != GIMPLE_LABEL)
    1910              :     return;
    1911              : 
    1912              :   /* If the statement is a label, add the label to block-to-labels map
    1913              :      so that we can speed up edge creation for GIMPLE_GOTOs.  */
    1914     39392428 :   if (cfun->cfg)
    1915              :     {
    1916     39392314 :       tree t;
    1917     39392314 :       int uid;
    1918              : 
    1919     39392314 :       t = gimple_label_label (as_a <glabel *> (stmt));
    1920     39392314 :       uid = LABEL_DECL_UID (t);
    1921     39392314 :       if (uid == -1)
    1922              :         {
    1923     20097404 :           unsigned old_len =
    1924     20097404 :             vec_safe_length (label_to_block_map_for_fn (cfun));
    1925     20097404 :           LABEL_DECL_UID (t) = uid = cfun->cfg->last_label_uid++;
    1926     20097404 :           if (old_len <= (unsigned) uid)
    1927      9538000 :             vec_safe_grow_cleared (label_to_block_map_for_fn (cfun), uid + 1);
    1928              :         }
    1929              : 
    1930     39392314 :       (*label_to_block_map_for_fn (cfun))[uid] = bb;
    1931              :     }
    1932              : }
    1933              : 
    1934              : 
    1935              : /* Modify the RHS of the assignment pointed-to by GSI using the
    1936              :    operands in the expression tree EXPR.
    1937              : 
    1938              :    NOTE: The statement pointed-to by GSI may be reallocated if it
    1939              :    did not have enough operand slots.
    1940              : 
    1941              :    This function is useful to convert an existing tree expression into
    1942              :    the flat representation used for the RHS of a GIMPLE assignment.
    1943              :    It will reallocate memory as needed to expand or shrink the number
    1944              :    of operand slots needed to represent EXPR.
    1945              : 
    1946              :    NOTE: If you find yourself building a tree and then calling this
    1947              :    function, you are most certainly doing it the slow way.  It is much
    1948              :    better to build a new assignment or to use the function
    1949              :    gimple_assign_set_rhs_with_ops, which does not require an
    1950              :    expression tree to be built.  */
    1951              : 
    1952              : void
    1953      5340769 : gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *gsi, tree expr)
    1954              : {
    1955      5340769 :   enum tree_code subcode;
    1956      5340769 :   tree op1, op2, op3;
    1957              : 
    1958      5340769 :   extract_ops_from_tree (expr, &subcode, &op1, &op2, &op3);
    1959      5340769 :   gimple_assign_set_rhs_with_ops (gsi, subcode, op1, op2, op3);
    1960      5340769 : }
    1961              : 
    1962              : 
    1963              : /* Set the RHS of assignment statement pointed-to by GSI to CODE with
    1964              :    operands OP1, OP2 and OP3.
    1965              : 
    1966              :    NOTE: The statement pointed-to by GSI may be reallocated if it
    1967              :    did not have enough operand slots.  */
    1968              : 
    1969              : void
    1970      8089231 : gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code,
    1971              :                                 tree op1, tree op2, tree op3)
    1972              : {
    1973      8089231 :   unsigned new_rhs_ops = get_gimple_rhs_num_ops (code);
    1974      8089231 :   gimple *stmt = gsi_stmt (*gsi);
    1975      8089231 :   gimple *old_stmt = stmt;
    1976              : 
    1977              :   /* If the new CODE needs more operands, allocate a new statement.  */
    1978      8089231 :   if (gimple_num_ops (stmt) < new_rhs_ops + 1)
    1979              :     {
    1980       211419 :       tree lhs = gimple_assign_lhs (old_stmt);
    1981       211419 :       stmt = gimple_alloc (gimple_code (old_stmt), new_rhs_ops + 1);
    1982       211419 :       memcpy (stmt, old_stmt, gimple_size (gimple_code (old_stmt)));
    1983       211419 :       gimple_init_singleton (stmt);
    1984              : 
    1985              :       /* The LHS needs to be reset as this also changes the SSA name
    1986              :          on the LHS.  */
    1987       211419 :       gimple_assign_set_lhs (stmt, lhs);
    1988              :     }
    1989              : 
    1990      8089231 :   gimple_set_num_ops (stmt, new_rhs_ops + 1);
    1991      8089231 :   gimple_set_subcode (stmt, code);
    1992      8089231 :   gimple_assign_set_rhs1 (stmt, op1);
    1993      8089231 :   if (new_rhs_ops > 1)
    1994      1207440 :     gimple_assign_set_rhs2 (stmt, op2);
    1995      1207440 :   if (new_rhs_ops > 2)
    1996        37171 :     gimple_assign_set_rhs3 (stmt, op3);
    1997      8089231 :   if (stmt != old_stmt)
    1998       211419 :     gsi_replace (gsi, stmt, false);
    1999      8089231 : }
    2000              : 
    2001              : 
    2002              : /* Return the LHS of a statement that performs an assignment,
    2003              :    either a GIMPLE_ASSIGN or a GIMPLE_CALL.  Returns NULL_TREE
    2004              :    for a call to a function that returns no value, or for a
    2005              :    statement other than an assignment or a call.  */
    2006              : 
    2007              : tree
    2008   7650591817 : gimple_get_lhs (const gimple *stmt)
    2009              : {
    2010   7650591817 :   enum gimple_code code = gimple_code (stmt);
    2011              : 
    2012   7650591817 :   if (code == GIMPLE_ASSIGN)
    2013   4769217999 :     return gimple_assign_lhs (stmt);
    2014   2881373818 :   else if (code == GIMPLE_CALL)
    2015    545652086 :     return gimple_call_lhs (stmt);
    2016   2335721732 :   else if (code == GIMPLE_PHI)
    2017    147252938 :     return gimple_phi_result (stmt);
    2018              :   else
    2019              :     return NULL_TREE;
    2020              : }
    2021              : 
    2022              : 
    2023              : /* Set the LHS of a statement that performs an assignment,
    2024              :    either a GIMPLE_ASSIGN or a GIMPLE_CALL.  */
    2025              : 
    2026              : void
    2027      2258779 : gimple_set_lhs (gimple *stmt, tree lhs)
    2028              : {
    2029      2258779 :   enum gimple_code code = gimple_code (stmt);
    2030              : 
    2031      2258779 :   if (code == GIMPLE_ASSIGN)
    2032      1058243 :     gimple_assign_set_lhs (stmt, lhs);
    2033      1200536 :   else if (code == GIMPLE_CALL)
    2034      1200536 :     gimple_call_set_lhs (stmt, lhs);
    2035              :   else
    2036            0 :     gcc_unreachable ();
    2037      2258779 : }
    2038              : 
    2039              : 
    2040              : /* Return a deep copy of statement STMT.  All the operands from STMT
    2041              :    are reallocated and copied using unshare_expr.  The DEF, USE, VDEF
    2042              :    and VUSE operand arrays are set to empty in the new copy.  The new
    2043              :    copy isn't part of any sequence.  */
    2044              : 
    2045              : gimple *
    2046     75243778 : gimple_copy (const gimple *stmt)
    2047              : {
    2048     75243778 :   enum gimple_code code = gimple_code (stmt);
    2049     75243778 :   unsigned num_ops = gimple_num_ops (stmt);
    2050     75243778 :   gimple *copy = gimple_alloc (code, num_ops);
    2051     75243778 :   unsigned i;
    2052              : 
    2053              :   /* Shallow copy all the fields from STMT.  */
    2054     75243778 :   memcpy (copy, stmt, gimple_size (code));
    2055     75243778 :   gimple_init_singleton (copy);
    2056              : 
    2057              :   /* If STMT has sub-statements, deep-copy them as well.  */
    2058     75243778 :   if (gimple_has_substatements (stmt))
    2059              :     {
    2060        42607 :       gimple_seq new_seq;
    2061        42607 :       tree t;
    2062              : 
    2063        42607 :       switch (gimple_code (stmt))
    2064              :         {
    2065          359 :         case GIMPLE_BIND:
    2066          359 :           {
    2067          359 :             const gbind *bind_stmt = as_a <const gbind *> (stmt);
    2068          359 :             gbind *bind_copy = as_a <gbind *> (copy);
    2069          359 :             new_seq = gimple_seq_copy (gimple_bind_body (bind_stmt));
    2070          359 :             gimple_bind_set_body (bind_copy, new_seq);
    2071          359 :             gimple_bind_set_vars (bind_copy,
    2072              :                                   unshare_expr (gimple_bind_vars (bind_stmt)));
    2073          359 :             gimple_bind_set_block (bind_copy, gimple_bind_block (bind_stmt));
    2074              :           }
    2075          359 :           break;
    2076              : 
    2077        17498 :         case GIMPLE_CATCH:
    2078        17498 :           {
    2079        17498 :             const gcatch *catch_stmt = as_a <const gcatch *> (stmt);
    2080        17498 :             gcatch *catch_copy = as_a <gcatch *> (copy);
    2081        17498 :             new_seq = gimple_seq_copy (gimple_catch_handler (catch_stmt));
    2082        17498 :             gimple_catch_set_handler (catch_copy, new_seq);
    2083        17498 :             t = unshare_expr (gimple_catch_types (catch_stmt));
    2084        17498 :             gimple_catch_set_types (catch_copy, t);
    2085              :           }
    2086        17498 :           break;
    2087              : 
    2088            0 :         case GIMPLE_EH_FILTER:
    2089            0 :           {
    2090            0 :             const geh_filter *eh_filter_stmt = as_a <const geh_filter *> (stmt);
    2091            0 :             geh_filter *eh_filter_copy = as_a <geh_filter *> (copy);
    2092            0 :             new_seq
    2093            0 :               = gimple_seq_copy (gimple_eh_filter_failure (eh_filter_stmt));
    2094            0 :             gimple_eh_filter_set_failure (eh_filter_copy, new_seq);
    2095            0 :             t = unshare_expr (gimple_eh_filter_types (eh_filter_stmt));
    2096            0 :             gimple_eh_filter_set_types (eh_filter_copy, t);
    2097              :           }
    2098            0 :           break;
    2099              : 
    2100          273 :         case GIMPLE_EH_ELSE:
    2101          273 :           {
    2102          273 :             const geh_else *eh_else_stmt = as_a <const geh_else *> (stmt);
    2103          273 :             geh_else *eh_else_copy = as_a <geh_else *> (copy);
    2104          273 :             new_seq = gimple_seq_copy (gimple_eh_else_n_body (eh_else_stmt));
    2105          273 :             gimple_eh_else_set_n_body (eh_else_copy, new_seq);
    2106          273 :             new_seq = gimple_seq_copy (gimple_eh_else_e_body (eh_else_stmt));
    2107          273 :             gimple_eh_else_set_e_body (eh_else_copy, new_seq);
    2108              :           }
    2109          273 :           break;
    2110              : 
    2111        24191 :         case GIMPLE_TRY:
    2112        24191 :           {
    2113        24191 :             const gtry *try_stmt = as_a <const gtry *> (stmt);
    2114        24191 :             gtry *try_copy = as_a <gtry *> (copy);
    2115        24191 :             new_seq = gimple_seq_copy (gimple_try_eval (try_stmt));
    2116        24191 :             gimple_try_set_eval (try_copy, new_seq);
    2117        24191 :             new_seq = gimple_seq_copy (gimple_try_cleanup (try_stmt));
    2118        24191 :             gimple_try_set_cleanup (try_copy, new_seq);
    2119              :           }
    2120        24191 :           break;
    2121              : 
    2122          280 :         case GIMPLE_OMP_FOR:
    2123          280 :           new_seq = gimple_seq_copy (gimple_omp_for_pre_body (stmt));
    2124          280 :           gimple_omp_for_set_pre_body (copy, new_seq);
    2125          280 :           t = unshare_expr (gimple_omp_for_clauses (stmt));
    2126          280 :           gimple_omp_for_set_clauses (copy, t);
    2127          280 :           {
    2128          280 :             gomp_for *omp_for_copy = as_a <gomp_for *> (copy);
    2129          280 :             omp_for_copy->iter = ggc_vec_alloc<gimple_omp_for_iter>
    2130          280 :               ( gimple_omp_for_collapse (stmt));
    2131              :           }
    2132          576 :           for (i = 0; i < gimple_omp_for_collapse (stmt); i++)
    2133              :             {
    2134          296 :               gimple_omp_for_set_cond (copy, i,
    2135              :                                        gimple_omp_for_cond (stmt, i));
    2136          296 :               gimple_omp_for_set_index (copy, i,
    2137              :                                         gimple_omp_for_index (stmt, i));
    2138          296 :               t = unshare_expr (gimple_omp_for_initial (stmt, i));
    2139          296 :               gimple_omp_for_set_initial (copy, i, t);
    2140          296 :               t = unshare_expr (gimple_omp_for_final (stmt, i));
    2141          296 :               gimple_omp_for_set_final (copy, i, t);
    2142          296 :               t = unshare_expr (gimple_omp_for_incr (stmt, i));
    2143          296 :               gimple_omp_for_set_incr (copy, i, t);
    2144              :             }
    2145          280 :           goto copy_omp_body;
    2146              : 
    2147            0 :         case GIMPLE_OMP_PARALLEL:
    2148            0 :           {
    2149            0 :             const gomp_parallel *omp_par_stmt
    2150            0 :               = as_a <const gomp_parallel *> (stmt);
    2151            0 :             gomp_parallel *omp_par_copy = as_a <gomp_parallel *> (copy);
    2152            0 :             t = unshare_expr (gimple_omp_parallel_clauses (omp_par_stmt));
    2153            0 :             gimple_omp_parallel_set_clauses (omp_par_copy, t);
    2154            0 :             t = unshare_expr (gimple_omp_parallel_child_fn (omp_par_stmt));
    2155            0 :             gimple_omp_parallel_set_child_fn (omp_par_copy, t);
    2156            0 :             t = unshare_expr (gimple_omp_parallel_data_arg (omp_par_stmt));
    2157            0 :             gimple_omp_parallel_set_data_arg (omp_par_copy, t);
    2158              :           }
    2159            0 :           goto copy_omp_body;
    2160              : 
    2161            0 :         case GIMPLE_OMP_TASK:
    2162            0 :           t = unshare_expr (gimple_omp_task_clauses (stmt));
    2163            0 :           gimple_omp_task_set_clauses (copy, t);
    2164            0 :           t = unshare_expr (gimple_omp_task_child_fn (stmt));
    2165            0 :           gimple_omp_task_set_child_fn (copy, t);
    2166            0 :           t = unshare_expr (gimple_omp_task_data_arg (stmt));
    2167            0 :           gimple_omp_task_set_data_arg (copy, t);
    2168            0 :           t = unshare_expr (gimple_omp_task_copy_fn (stmt));
    2169            0 :           gimple_omp_task_set_copy_fn (copy, t);
    2170            0 :           t = unshare_expr (gimple_omp_task_arg_size (stmt));
    2171            0 :           gimple_omp_task_set_arg_size (copy, t);
    2172            0 :           t = unshare_expr (gimple_omp_task_arg_align (stmt));
    2173            0 :           gimple_omp_task_set_arg_align (copy, t);
    2174            0 :           goto copy_omp_body;
    2175              : 
    2176            0 :         case GIMPLE_OMP_CRITICAL:
    2177            0 :           t = unshare_expr (gimple_omp_critical_name
    2178              :                                 (as_a <const gomp_critical *> (stmt)));
    2179            0 :           gimple_omp_critical_set_name (as_a <gomp_critical *> (copy), t);
    2180            0 :           t = unshare_expr (gimple_omp_critical_clauses
    2181              :                                 (as_a <const gomp_critical *> (stmt)));
    2182            0 :           gimple_omp_critical_set_clauses (as_a <gomp_critical *> (copy), t);
    2183            0 :           goto copy_omp_body;
    2184              : 
    2185            0 :         case GIMPLE_OMP_ORDERED:
    2186            0 :           t = unshare_expr (gimple_omp_ordered_clauses
    2187              :                                 (as_a <const gomp_ordered *> (stmt)));
    2188            0 :           gimple_omp_ordered_set_clauses (as_a <gomp_ordered *> (copy), t);
    2189            0 :           goto copy_omp_body;
    2190              : 
    2191            0 :         case GIMPLE_OMP_SCAN:
    2192            0 :           t = gimple_omp_scan_clauses (as_a <const gomp_scan *> (stmt));
    2193            0 :           t = unshare_expr (t);
    2194            0 :           gimple_omp_scan_set_clauses (as_a <gomp_scan *> (copy), t);
    2195            0 :           goto copy_omp_body;
    2196              : 
    2197            0 :         case GIMPLE_OMP_TASKGROUP:
    2198            0 :           t = unshare_expr (gimple_omp_taskgroup_clauses (stmt));
    2199            0 :           gimple_omp_taskgroup_set_clauses (copy, t);
    2200            0 :           goto copy_omp_body;
    2201              : 
    2202            0 :         case GIMPLE_OMP_SECTIONS:
    2203            0 :           t = unshare_expr (gimple_omp_sections_clauses (stmt));
    2204            0 :           gimple_omp_sections_set_clauses (copy, t);
    2205            0 :           t = unshare_expr (gimple_omp_sections_control (stmt));
    2206            0 :           gimple_omp_sections_set_control (copy, t);
    2207            0 :           goto copy_omp_body;
    2208              : 
    2209            0 :         case GIMPLE_OMP_SINGLE:
    2210            0 :           {
    2211            0 :             gomp_single *omp_single_copy = as_a <gomp_single *> (copy);
    2212            0 :             t = unshare_expr (gimple_omp_single_clauses (stmt));
    2213            0 :             gimple_omp_single_set_clauses (omp_single_copy, t);
    2214              :           }
    2215            0 :           goto copy_omp_body;
    2216              : 
    2217            0 :         case GIMPLE_OMP_SCOPE:
    2218            0 :           t = unshare_expr (gimple_omp_scope_clauses (stmt));
    2219            0 :           gimple_omp_scope_set_clauses (copy, t);
    2220            0 :           goto copy_omp_body;
    2221              : 
    2222            0 :         case GIMPLE_OMP_DISPATCH:
    2223            0 :           t = unshare_expr (gimple_omp_dispatch_clauses (stmt));
    2224            0 :           gimple_omp_dispatch_set_clauses (copy, t);
    2225            0 :           goto copy_omp_body;
    2226              : 
    2227            0 :         case GIMPLE_OMP_INTEROP:
    2228            0 :           t = unshare_expr (gimple_omp_interop_clauses (stmt));
    2229            0 :           gimple_omp_interop_set_clauses (copy, t);
    2230            0 :           break;
    2231              : 
    2232            0 :         case GIMPLE_OMP_TARGET:
    2233            0 :           {
    2234            0 :             const gomp_target *omp_target_stmt
    2235            0 :               = as_a <const gomp_target *> (stmt);
    2236            0 :             gomp_target *omp_target_copy = as_a <gomp_target *> (copy);
    2237            0 :             t = unshare_expr (gimple_omp_target_clauses (omp_target_stmt));
    2238            0 :             gimple_omp_target_set_clauses (omp_target_copy, t);
    2239            0 :             t = unshare_expr (gimple_omp_target_data_arg (omp_target_stmt));
    2240            0 :             gimple_omp_target_set_data_arg (omp_target_copy, t);
    2241              :           }
    2242            0 :           goto copy_omp_body;
    2243              : 
    2244            0 :         case GIMPLE_OMP_TEAMS:
    2245            0 :           {
    2246            0 :             gomp_teams *omp_teams_copy = as_a <gomp_teams *> (copy);
    2247            0 :             t = unshare_expr (gimple_omp_teams_clauses (stmt));
    2248            0 :             gimple_omp_teams_set_clauses (omp_teams_copy, t);
    2249              :           }
    2250              :           /* FALLTHRU  */
    2251              : 
    2252          280 :         case GIMPLE_OMP_SECTION:
    2253          280 :         case GIMPLE_OMP_MASTER:
    2254          280 :         case GIMPLE_OMP_STRUCTURED_BLOCK:
    2255          280 :         copy_omp_body:
    2256          280 :           new_seq = gimple_seq_copy (gimple_omp_body (stmt));
    2257          280 :           gimple_omp_set_body (copy, new_seq);
    2258          280 :           break;
    2259              : 
    2260            0 :         case GIMPLE_OMP_MASKED:
    2261            0 :           t = unshare_expr (gimple_omp_masked_clauses (stmt));
    2262            0 :           gimple_omp_masked_set_clauses (copy, t);
    2263            0 :           goto copy_omp_body;
    2264              : 
    2265            0 :         case GIMPLE_ASSUME:
    2266            0 :           new_seq = gimple_seq_copy (gimple_assume_body (stmt));
    2267            0 :           *gimple_assume_body_ptr (copy) = new_seq;
    2268            0 :           gimple_assume_set_guard (copy,
    2269              :                                    unshare_expr (gimple_assume_guard (stmt)));
    2270            0 :           break;
    2271              : 
    2272            6 :         case GIMPLE_TRANSACTION:
    2273            6 :           new_seq = gimple_seq_copy (gimple_transaction_body (
    2274              :                                        as_a <const gtransaction *> (stmt)));
    2275            6 :           gimple_transaction_set_body (as_a <gtransaction *> (copy),
    2276              :                                        new_seq);
    2277            6 :           break;
    2278              : 
    2279            0 :         case GIMPLE_WITH_CLEANUP_EXPR:
    2280            0 :           new_seq = gimple_seq_copy (gimple_wce_cleanup (stmt));
    2281            0 :           gimple_wce_set_cleanup (copy, new_seq);
    2282            0 :           break;
    2283              : 
    2284            0 :         default:
    2285            0 :           gcc_unreachable ();
    2286              :         }
    2287              :     }
    2288              : 
    2289     75243778 :   switch (gimple_code (stmt))
    2290              :     {
    2291            0 :     case GIMPLE_OMP_ATOMIC_LOAD:
    2292            0 :       {
    2293            0 :         gomp_atomic_load *g = as_a <gomp_atomic_load *> (copy);
    2294            0 :         gimple_omp_atomic_load_set_lhs (g,
    2295              :           unshare_expr (gimple_omp_atomic_load_lhs (g)));
    2296            0 :         gimple_omp_atomic_load_set_rhs (g,
    2297              :           unshare_expr (gimple_omp_atomic_load_rhs (g)));
    2298            0 :         break;
    2299              :       }
    2300            0 :     case GIMPLE_OMP_ATOMIC_STORE:
    2301            0 :       {
    2302            0 :         gomp_atomic_store *g = as_a <gomp_atomic_store *> (copy);
    2303            0 :         gimple_omp_atomic_store_set_val (g,
    2304              :           unshare_expr (gimple_omp_atomic_store_val (g)));
    2305            0 :         break;
    2306              :       }
    2307              :     default:
    2308              :       break;
    2309              :     }
    2310              : 
    2311              :   /* Make copy of operands.  */
    2312    229911021 :   for (i = 0; i < num_ops; i++)
    2313    154667243 :     gimple_set_op (copy, i, unshare_expr (gimple_op (stmt, i)));
    2314              : 
    2315     75243778 :   if (gimple_has_mem_ops (stmt))
    2316              :     {
    2317     34491578 :       gimple_set_vdef (copy, gimple_vdef (stmt));
    2318     34491578 :       gimple_set_vuse (copy, gimple_vuse (stmt));
    2319              :     }
    2320              : 
    2321              :   /* Clear out SSA operand vectors on COPY.  */
    2322     75243778 :   if (gimple_has_ops (stmt))
    2323              :     {
    2324     74789746 :       gimple_set_use_ops (copy, NULL);
    2325              : 
    2326              :       /* SSA operands need to be updated.  */
    2327     74789746 :       gimple_set_modified (copy, true);
    2328              :     }
    2329              : 
    2330     75243778 :   if (gimple_debug_nonbind_marker_p (stmt))
    2331     16536350 :     cfun->debug_marker_count++;
    2332              : 
    2333     75243778 :   return copy;
    2334              : }
    2335              : 
    2336              : /* Move OLD_STMT's vuse and vdef operands to NEW_STMT, on the assumption
    2337              :    that OLD_STMT is about to be removed.  */
    2338              : 
    2339              : void
    2340       729725 : gimple_move_vops (gimple *new_stmt, const gimple *old_stmt)
    2341              : {
    2342       729725 :   tree vdef = gimple_vdef (old_stmt);
    2343      1459450 :   gimple_set_vuse (new_stmt, gimple_vuse (old_stmt));
    2344       729725 :   gimple_set_vdef (new_stmt, vdef);
    2345       729725 :   if (vdef && TREE_CODE (vdef) == SSA_NAME)
    2346       261169 :     SSA_NAME_DEF_STMT (vdef) = new_stmt;
    2347       729725 : }
    2348              : 
    2349              : /* Return true if statement S has side-effects.  We consider a
    2350              :    statement to have side effects if:
    2351              : 
    2352              :    - It is a GIMPLE_CALL not marked with ECF_PURE or ECF_CONST.
    2353              :    - Any of its operands are marked TREE_THIS_VOLATILE or TREE_SIDE_EFFECTS.  */
    2354              : 
    2355              : bool
    2356    891865937 : gimple_has_side_effects (const gimple *s)
    2357              : {
    2358    891865937 :   if (is_gimple_debug (s))
    2359              :     return false;
    2360              : 
    2361              :   /* We don't have to scan the arguments to check for
    2362              :      volatile arguments, though, at present, we still
    2363              :      do a scan to check for TREE_SIDE_EFFECTS.  */
    2364   1349026048 :   if (gimple_has_volatile_ops (s))
    2365              :     return true;
    2366              : 
    2367    677025123 :   if (gimple_code (s) == GIMPLE_ASM
    2368    677025123 :       && gimple_asm_volatile_p (as_a <const gasm *> (s)))
    2369              :     return true;
    2370              : 
    2371    676484384 :   if (is_gimple_call (s))
    2372              :     {
    2373     96487946 :       int flags = gimple_call_flags (s);
    2374              : 
    2375              :       /* An infinite loop is considered a side effect.  */
    2376     96487946 :       if (!(flags & (ECF_CONST | ECF_PURE))
    2377     18985666 :           || (flags & ECF_LOOPING_CONST_OR_PURE))
    2378              :         return true;
    2379              : 
    2380     16942271 :       return false;
    2381              :     }
    2382              : 
    2383              :   return false;
    2384              : }
    2385              : 
    2386              : /* Helper for gimple_could_trap_p and gimple_assign_rhs_could_trap_p.
    2387              :    Return true if S can trap.  When INCLUDE_MEM is true, check whether
    2388              :    the memory operations could trap.  When INCLUDE_STORES is true, also
    2389              :    check a memory LHS with store semantics.  */
    2390              : 
    2391              : bool
    2392     77122364 : gimple_could_trap_p_1 (const gimple *s, bool include_mem, bool include_stores)
    2393              : {
    2394     77122364 :   tree t, div = NULL_TREE;
    2395     77122364 :   enum tree_code op;
    2396              : 
    2397     77122364 :   if (include_mem)
    2398              :     {
    2399     52108652 :       unsigned i, start = 0;
    2400              : 
    2401              :       /* Use store semantics for the LHS.  A call marked for return-slot
    2402              :          optimization can still use a temporary and a caller-side copy.  */
    2403     52108652 :       if (include_stores
    2404     47825911 :           && gimple_store_p (s)
    2405     56835336 :           && lhs_could_trap_p (gimple_get_lhs (s)))
    2406              :         return true;
    2407              : 
    2408     52443780 :       if (gimple_has_lhs (s))
    2409     51531000 :         start = 1;
    2410              : 
    2411    133116252 :       for (i = start; i < gimple_num_ops (s); i++)
    2412     86352330 :         if (tree_could_trap_p (gimple_op (s, i)))
    2413              :           return true;
    2414              :     }
    2415              : 
    2416     71777634 :   switch (gimple_code (s))
    2417              :     {
    2418        10427 :     case GIMPLE_ASM:
    2419        10427 :       return gimple_asm_volatile_p (as_a <const gasm *> (s));
    2420              : 
    2421      1603686 :     case GIMPLE_CALL:
    2422      1603686 :       {
    2423      1603686 :         if (gimple_call_internal_p (s))
    2424              :           return false;
    2425      1377240 :         t = gimple_call_fndecl (s);
    2426              :         /* Assume that indirect and calls to weak functions may trap.  */
    2427      1377240 :         if (!t || !DECL_P (t) || DECL_WEAK (t))
    2428              :           return true;
    2429              : 
    2430              :         /* Any floating point builtin operation could trap.  */
    2431      1352795 :         if (gimple_call_builtin_p (s))
    2432              :           {
    2433       992277 :             if (fndecl_built_in_p (t, BUILT_IN_NORMAL))
    2434       886402 :               switch (DECL_FUNCTION_CODE (t))
    2435              :                 {
    2436              :                 CASE_FLT_FN (BUILT_IN_COPYSIGN):
    2437              :                 CASE_FLT_FN_FLOATN_NX (BUILT_IN_COPYSIGN):
    2438              :                   return false;
    2439              :                 default:
    2440              :                   break;
    2441              :                 }
    2442       941989 :             tree type = TREE_TYPE (gimple_call_fntype (s));
    2443       941989 :             bool fp_operation = FLOAT_TYPE_P (type);
    2444        53982 :             return fp_operation && flag_trapping_math;
    2445              :           }
    2446              :         return false;
    2447              :       }
    2448     58861264 :     case GIMPLE_ASSIGN:
    2449     58861264 :       op = gimple_assign_rhs_code (s);
    2450              : 
    2451              :       /* COND_EXPR does not trap.  */
    2452     58861264 :       if (op == COND_EXPR || op == VEC_COND_EXPR)
    2453              :         return false;
    2454              : 
    2455              :       /* For comparisons we need to check rhs operand types instead of lhs type
    2456              :          (which is BOOLEAN_TYPE).  */
    2457     58748835 :       if (TREE_CODE_CLASS (op) == tcc_comparison
    2458     56135850 :           || op == FIX_TRUNC_EXPR)
    2459      2655109 :         t = TREE_TYPE (gimple_assign_rhs1 (s));
    2460              :       else
    2461     56093726 :         t = TREE_TYPE (gimple_assign_lhs (s));
    2462              : 
    2463     58748835 :       if (get_gimple_rhs_class (op) == GIMPLE_BINARY_RHS)
    2464     35423516 :         div = gimple_assign_rhs2 (s);
    2465              : 
    2466     61867261 :       return (operation_could_trap_p (op, FLOAT_TYPE_P (t),
    2467     58748835 :                                       (INTEGRAL_TYPE_P (t)
    2468     44878389 :                                        && TYPE_OVERFLOW_TRAPS (t)),
    2469     58748835 :                                       div));
    2470              : 
    2471      6410838 :     case GIMPLE_COND:
    2472      6410838 :       t = TREE_TYPE (gimple_cond_lhs (s));
    2473      6410838 :       return operation_could_trap_p (gimple_cond_code (s),
    2474     12821676 :                                      FLOAT_TYPE_P (t), false, NULL_TREE);
    2475              : 
    2476              :     default:
    2477              :       break;
    2478              :     }
    2479              : 
    2480              :   return false;
    2481              : }
    2482              : 
    2483              : /* Return true if statement S can trap.  */
    2484              : 
    2485              : bool
    2486     47825911 : gimple_could_trap_p (const gimple *s)
    2487              : {
    2488     47825911 :   return gimple_could_trap_p_1 (s, true, true);
    2489              : }
    2490              : 
    2491              : /* Return true if RHS of a GIMPLE_ASSIGN S can trap.  */
    2492              : 
    2493              : bool
    2494      3304998 : gimple_assign_rhs_could_trap_p (const gimple *s)
    2495              : {
    2496      3304998 :   gcc_assert (is_gimple_assign (s));
    2497      3304998 :   return gimple_could_trap_p_1 (s, true, false);
    2498              : }
    2499              : 
    2500              : 
    2501              : /* Print debugging information for gimple stmts generated.  */
    2502              : 
    2503              : void
    2504            0 : dump_gimple_statistics (void)
    2505              : {
    2506            0 :   int i;
    2507            0 :   uint64_t total_tuples = 0, total_bytes = 0;
    2508              : 
    2509            0 :   if (! GATHER_STATISTICS)
    2510              :     {
    2511            0 :       fprintf (stderr, "No GIMPLE statistics\n");
    2512            0 :       return;
    2513              :     }
    2514              : 
    2515              :   fprintf (stderr, "\nGIMPLE statements\n");
    2516              :   fprintf (stderr, "Kind                   Stmts      Bytes\n");
    2517              :   fprintf (stderr, "---------------------------------------\n");
    2518              :   for (i = 0; i < (int) gimple_alloc_kind_all; ++i)
    2519              :     {
    2520              :       fprintf (stderr, "%-20s %7" PRIu64 "%c %10" PRIu64 "%c\n",
    2521              :                gimple_alloc_kind_names[i],
    2522              :                SIZE_AMOUNT (gimple_alloc_counts[i]),
    2523              :                SIZE_AMOUNT (gimple_alloc_sizes[i]));
    2524              :       total_tuples += gimple_alloc_counts[i];
    2525              :       total_bytes += gimple_alloc_sizes[i];
    2526              :     }
    2527              :   fprintf (stderr, "---------------------------------------\n");
    2528              :   fprintf (stderr, "%-20s %7" PRIu64 "%c %10" PRIu64 "%c\n", "Total",
    2529              :            SIZE_AMOUNT (total_tuples), SIZE_AMOUNT (total_bytes));
    2530              :   fprintf (stderr, "---------------------------------------\n");
    2531              : }
    2532              : 
    2533              : 
    2534              : /* Return the number of operands needed on the RHS of a GIMPLE
    2535              :    assignment for an expression with tree code CODE.  */
    2536              : 
    2537              : unsigned
    2538    104925237 : get_gimple_rhs_num_ops (enum tree_code code)
    2539              : {
    2540    104925237 :   switch (get_gimple_rhs_class (code))
    2541              :     {
    2542              :     case GIMPLE_UNARY_RHS:
    2543              :     case GIMPLE_SINGLE_RHS:
    2544              :       return 1;
    2545              :     case GIMPLE_BINARY_RHS:
    2546              :       return 2;
    2547              :     case GIMPLE_TERNARY_RHS:
    2548              :       return 3;
    2549            0 :     default:
    2550            0 :       gcc_unreachable ();
    2551              :     }
    2552              : }
    2553              : 
    2554              : #define DEFTREECODE(SYM, STRING, TYPE, NARGS)                               \
    2555              :   (unsigned char)                                                           \
    2556              :   ((TYPE) == tcc_unary ? GIMPLE_UNARY_RHS                                   \
    2557              :    : ((TYPE) == tcc_binary                                                  \
    2558              :       || (TYPE) == tcc_comparison) ? GIMPLE_BINARY_RHS                      \
    2559              :    : ((TYPE) == tcc_constant                                                \
    2560              :       || (TYPE) == tcc_declaration                                          \
    2561              :       || (TYPE) == tcc_reference) ? GIMPLE_SINGLE_RHS                       \
    2562              :    : ((SYM) == TRUTH_AND_EXPR                                               \
    2563              :       || (SYM) == TRUTH_OR_EXPR                                             \
    2564              :       || (SYM) == TRUTH_XOR_EXPR) ? GIMPLE_BINARY_RHS                       \
    2565              :    : (SYM) == TRUTH_NOT_EXPR ? GIMPLE_UNARY_RHS                             \
    2566              :    : ((SYM) == COND_EXPR                                                    \
    2567              :       || (SYM) == WIDEN_MULT_PLUS_EXPR                                      \
    2568              :       || (SYM) == WIDEN_MULT_MINUS_EXPR                                     \
    2569              :       || (SYM) == DOT_PROD_EXPR                                             \
    2570              :       || (SYM) == SAD_EXPR                                                  \
    2571              :       || (SYM) == REALIGN_LOAD_EXPR                                         \
    2572              :       || (SYM) == VEC_COND_EXPR                                             \
    2573              :       || (SYM) == VEC_PERM_EXPR                                             \
    2574              :       || (SYM) == BIT_INSERT_EXPR) ? GIMPLE_TERNARY_RHS                     \
    2575              :    : ((SYM) == CONSTRUCTOR                                                  \
    2576              :       || (SYM) == OBJ_TYPE_REF                                              \
    2577              :       || (SYM) == ADDR_EXPR                                                 \
    2578              :       || (SYM) == WITH_SIZE_EXPR                                            \
    2579              :       || (SYM) == SSA_NAME                                                  \
    2580              :       || (SYM) == OMP_NEXT_VARIANT                                          \
    2581              :       || (SYM) == OMP_TARGET_DEVICE_MATCHES) ? GIMPLE_SINGLE_RHS            \
    2582              :    : GIMPLE_INVALID_RHS),
    2583              : #define END_OF_BASE_TREE_CODES (unsigned char) GIMPLE_INVALID_RHS,
    2584              : 
    2585              : const unsigned char gimple_rhs_class_table[] = {
    2586              : #include "all-tree.def"
    2587              : };
    2588              : 
    2589              : #undef DEFTREECODE
    2590              : #undef END_OF_BASE_TREE_CODES
    2591              : 
    2592              : /* Build a GIMPLE_CALL identical to STMT but skipping the arguments in
    2593              :    the positions marked by the set ARGS_TO_SKIP.  */
    2594              : 
    2595              : gcall *
    2596            0 : gimple_call_copy_skip_args (const gcall *stmt, const_bitmap args_to_skip)
    2597              : {
    2598            0 :   int i;
    2599            0 :   int nargs = gimple_call_num_args (stmt);
    2600            0 :   auto_vec<tree> vargs (nargs);
    2601            0 :   gcall *new_stmt;
    2602              : 
    2603            0 :   for (i = 0; i < nargs; i++)
    2604            0 :     if (!bitmap_bit_p (args_to_skip, i))
    2605            0 :       vargs.quick_push (gimple_call_arg (stmt, i));
    2606              : 
    2607            0 :   if (gimple_call_internal_p (stmt))
    2608            0 :     new_stmt = gimple_build_call_internal_vec (gimple_call_internal_fn (stmt),
    2609              :                                                vargs);
    2610              :   else
    2611            0 :     new_stmt = gimple_build_call_vec (gimple_call_fn (stmt), vargs);
    2612              : 
    2613            0 :   if (gimple_call_lhs (stmt))
    2614            0 :     gimple_call_set_lhs (new_stmt, gimple_call_lhs (stmt));
    2615              : 
    2616            0 :   gimple_set_vuse (new_stmt, gimple_vuse (stmt));
    2617            0 :   gimple_set_vdef (new_stmt, gimple_vdef (stmt));
    2618              : 
    2619            0 :   if (gimple_has_location (stmt))
    2620            0 :     gimple_set_location (new_stmt, gimple_location (stmt));
    2621            0 :   gimple_call_copy_flags (new_stmt, stmt);
    2622            0 :   gimple_call_set_chain (new_stmt, gimple_call_chain (stmt));
    2623              : 
    2624            0 :   gimple_set_modified (new_stmt, true);
    2625              : 
    2626            0 :   return new_stmt;
    2627            0 : }
    2628              : 
    2629              : 
    2630              : 
    2631              : /* Return true if the field decls F1 and F2 are at the same offset.
    2632              : 
    2633              :    This is intended to be used on GIMPLE types only.  */
    2634              : 
    2635              : bool
    2636     61759967 : gimple_compare_field_offset (const_tree f1, const_tree f2)
    2637              : {
    2638     61759967 :   if (DECL_OFFSET_ALIGN (f1) == DECL_OFFSET_ALIGN (f2))
    2639              :     {
    2640     61759904 :       tree offset1 = DECL_FIELD_OFFSET (f1);
    2641     61759904 :       tree offset2 = DECL_FIELD_OFFSET (f2);
    2642     61759904 :       return ((offset1 == offset2
    2643              :                /* Once gimplification is done, self-referential offsets are
    2644              :                   instantiated as operand #2 of the COMPONENT_REF built for
    2645              :                   each access and reset.  Therefore, they are not relevant
    2646              :                   anymore and fields are interchangeable provided that they
    2647              :                   represent the same access.  */
    2648            0 :                || (TREE_CODE (offset1) == PLACEHOLDER_EXPR
    2649            0 :                    && TREE_CODE (offset2) == PLACEHOLDER_EXPR
    2650            0 :                    && (DECL_SIZE (f1) == DECL_SIZE (f2)
    2651            0 :                        || (TREE_CODE (DECL_SIZE (f1)) == PLACEHOLDER_EXPR
    2652            0 :                            && TREE_CODE (DECL_SIZE (f2)) == PLACEHOLDER_EXPR)
    2653            0 :                        || operand_equal_p (DECL_SIZE (f1), DECL_SIZE (f2), 0))
    2654            0 :                    && DECL_ALIGN (f1) == DECL_ALIGN (f2))
    2655            0 :                || operand_equal_p (offset1, offset2, 0))
    2656    123519808 :               && tree_int_cst_equal (DECL_FIELD_BIT_OFFSET (f1),
    2657     61759904 :                                      DECL_FIELD_BIT_OFFSET (f2)));
    2658              :     }
    2659              : 
    2660              :   /* Fortran and C do not always agree on what DECL_OFFSET_ALIGN
    2661              :      should be, so handle differing ones specially by decomposing
    2662              :      the offset into a byte and bit offset manually.  */
    2663           63 :   if (tree_fits_shwi_p (DECL_FIELD_OFFSET (f1))
    2664           63 :       && tree_fits_shwi_p (DECL_FIELD_OFFSET (f2)))
    2665              :     {
    2666           63 :       unsigned HOST_WIDE_INT byte_offset1, byte_offset2;
    2667           63 :       unsigned HOST_WIDE_INT bit_offset1, bit_offset2;
    2668           63 :       bit_offset1 = TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (f1));
    2669           63 :       byte_offset1 = (TREE_INT_CST_LOW (DECL_FIELD_OFFSET (f1))
    2670           63 :                       + bit_offset1 / BITS_PER_UNIT);
    2671           63 :       bit_offset2 = TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (f2));
    2672           63 :       byte_offset2 = (TREE_INT_CST_LOW (DECL_FIELD_OFFSET (f2))
    2673           63 :                       + bit_offset2 / BITS_PER_UNIT);
    2674           63 :       if (byte_offset1 != byte_offset2)
    2675              :         return false;
    2676           63 :       return bit_offset1 % BITS_PER_UNIT == bit_offset2 % BITS_PER_UNIT;
    2677              :     }
    2678              : 
    2679              :   return false;
    2680              : }
    2681              : 
    2682              : 
    2683              : /* Return a type the same as TYPE except unsigned or
    2684              :    signed according to UNSIGNEDP.  */
    2685              : 
    2686              : static tree
    2687       740524 : gimple_signed_or_unsigned_type (bool unsignedp, tree type)
    2688              : {
    2689       740524 :   tree type1;
    2690       740524 :   int i;
    2691              : 
    2692       740524 :   type1 = TYPE_MAIN_VARIANT (type);
    2693       740524 :   if (type1 == signed_char_type_node
    2694       740524 :       || type1 == char_type_node
    2695       740524 :       || type1 == unsigned_char_type_node)
    2696            0 :     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
    2697       740524 :   if (type1 == integer_type_node || type1 == unsigned_type_node)
    2698       480510 :     return unsignedp ? unsigned_type_node : integer_type_node;
    2699       260014 :   if (type1 == short_integer_type_node || type1 == short_unsigned_type_node)
    2700       234007 :     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
    2701        26007 :   if (type1 == long_integer_type_node || type1 == long_unsigned_type_node)
    2702           30 :     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
    2703        25977 :   if (type1 == long_long_integer_type_node
    2704        25888 :       || type1 == long_long_unsigned_type_node)
    2705           89 :     return unsignedp
    2706           89 :            ? long_long_unsigned_type_node
    2707            0 :            : long_long_integer_type_node;
    2708              : 
    2709        44345 :   for (i = 0; i < NUM_INT_N_ENTS; i ++)
    2710        25888 :     if (int_n_enabled_p[i]
    2711        25888 :         && (type1 == int_n_trees[i].unsigned_type
    2712        18829 :             || type1 == int_n_trees[i].signed_type))
    2713         7431 :         return unsignedp
    2714         7431 :           ? int_n_trees[i].unsigned_type
    2715         7431 :           : int_n_trees[i].signed_type;
    2716              : 
    2717              : #if HOST_BITS_PER_WIDE_INT >= 64
    2718        18457 :   if (type1 == intTI_type_node || type1 == unsigned_intTI_type_node)
    2719            0 :     return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
    2720              : #endif
    2721        18457 :   if (type1 == intDI_type_node || type1 == unsigned_intDI_type_node)
    2722            0 :     return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
    2723        18457 :   if (type1 == intSI_type_node || type1 == unsigned_intSI_type_node)
    2724            0 :     return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
    2725        18457 :   if (type1 == intHI_type_node || type1 == unsigned_intHI_type_node)
    2726            0 :     return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
    2727        18457 :   if (type1 == intQI_type_node || type1 == unsigned_intQI_type_node)
    2728            0 :     return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
    2729              : 
    2730              : #define GIMPLE_FIXED_TYPES(NAME)            \
    2731              :   if (type1 == short_ ## NAME ## _type_node \
    2732              :       || type1 == unsigned_short_ ## NAME ## _type_node) \
    2733              :     return unsignedp ? unsigned_short_ ## NAME ## _type_node \
    2734              :                      : short_ ## NAME ## _type_node; \
    2735              :   if (type1 == NAME ## _type_node \
    2736              :       || type1 == unsigned_ ## NAME ## _type_node) \
    2737              :     return unsignedp ? unsigned_ ## NAME ## _type_node \
    2738              :                      : NAME ## _type_node; \
    2739              :   if (type1 == long_ ## NAME ## _type_node \
    2740              :       || type1 == unsigned_long_ ## NAME ## _type_node) \
    2741              :     return unsignedp ? unsigned_long_ ## NAME ## _type_node \
    2742              :                      : long_ ## NAME ## _type_node; \
    2743              :   if (type1 == long_long_ ## NAME ## _type_node \
    2744              :       || type1 == unsigned_long_long_ ## NAME ## _type_node) \
    2745              :     return unsignedp ? unsigned_long_long_ ## NAME ## _type_node \
    2746              :                      : long_long_ ## NAME ## _type_node;
    2747              : 
    2748              : #define GIMPLE_FIXED_MODE_TYPES(NAME) \
    2749              :   if (type1 == NAME ## _type_node \
    2750              :       || type1 == u ## NAME ## _type_node) \
    2751              :     return unsignedp ? u ## NAME ## _type_node \
    2752              :                      : NAME ## _type_node;
    2753              : 
    2754              : #define GIMPLE_FIXED_TYPES_SAT(NAME) \
    2755              :   if (type1 == sat_ ## short_ ## NAME ## _type_node \
    2756              :       || type1 == sat_ ## unsigned_short_ ## NAME ## _type_node) \
    2757              :     return unsignedp ? sat_ ## unsigned_short_ ## NAME ## _type_node \
    2758              :                      : sat_ ## short_ ## NAME ## _type_node; \
    2759              :   if (type1 == sat_ ## NAME ## _type_node \
    2760              :       || type1 == sat_ ## unsigned_ ## NAME ## _type_node) \
    2761              :     return unsignedp ? sat_ ## unsigned_ ## NAME ## _type_node \
    2762              :                      : sat_ ## NAME ## _type_node; \
    2763              :   if (type1 == sat_ ## long_ ## NAME ## _type_node \
    2764              :       || type1 == sat_ ## unsigned_long_ ## NAME ## _type_node) \
    2765              :     return unsignedp ? sat_ ## unsigned_long_ ## NAME ## _type_node \
    2766              :                      : sat_ ## long_ ## NAME ## _type_node; \
    2767              :   if (type1 == sat_ ## long_long_ ## NAME ## _type_node \
    2768              :       || type1 == sat_ ## unsigned_long_long_ ## NAME ## _type_node) \
    2769              :     return unsignedp ? sat_ ## unsigned_long_long_ ## NAME ## _type_node \
    2770              :                      : sat_ ## long_long_ ## NAME ## _type_node;
    2771              : 
    2772              : #define GIMPLE_FIXED_MODE_TYPES_SAT(NAME)       \
    2773              :   if (type1 == sat_ ## NAME ## _type_node \
    2774              :       || type1 == sat_ ## u ## NAME ## _type_node) \
    2775              :     return unsignedp ? sat_ ## u ## NAME ## _type_node \
    2776              :                      : sat_ ## NAME ## _type_node;
    2777              : 
    2778        18457 :   GIMPLE_FIXED_TYPES (fract);
    2779        18457 :   GIMPLE_FIXED_TYPES_SAT (fract);
    2780        18457 :   GIMPLE_FIXED_TYPES (accum);
    2781        18457 :   GIMPLE_FIXED_TYPES_SAT (accum);
    2782              : 
    2783        18457 :   GIMPLE_FIXED_MODE_TYPES (qq);
    2784        18457 :   GIMPLE_FIXED_MODE_TYPES (hq);
    2785        18457 :   GIMPLE_FIXED_MODE_TYPES (sq);
    2786        18457 :   GIMPLE_FIXED_MODE_TYPES (dq);
    2787        18457 :   GIMPLE_FIXED_MODE_TYPES (tq);
    2788        18457 :   GIMPLE_FIXED_MODE_TYPES_SAT (qq);
    2789        18457 :   GIMPLE_FIXED_MODE_TYPES_SAT (hq);
    2790        18457 :   GIMPLE_FIXED_MODE_TYPES_SAT (sq);
    2791        18457 :   GIMPLE_FIXED_MODE_TYPES_SAT (dq);
    2792        18457 :   GIMPLE_FIXED_MODE_TYPES_SAT (tq);
    2793        18457 :   GIMPLE_FIXED_MODE_TYPES (ha);
    2794        18457 :   GIMPLE_FIXED_MODE_TYPES (sa);
    2795        18457 :   GIMPLE_FIXED_MODE_TYPES (da);
    2796        18457 :   GIMPLE_FIXED_MODE_TYPES (ta);
    2797        18457 :   GIMPLE_FIXED_MODE_TYPES_SAT (ha);
    2798        18457 :   GIMPLE_FIXED_MODE_TYPES_SAT (sa);
    2799        18457 :   GIMPLE_FIXED_MODE_TYPES_SAT (da);
    2800        18457 :   GIMPLE_FIXED_MODE_TYPES_SAT (ta);
    2801              : 
    2802              :   /* For ENUMERAL_TYPEs in C++, must check the mode of the types, not
    2803              :      the precision; they have precision set to match their range, but
    2804              :      may use a wider mode to match an ABI.  If we change modes, we may
    2805              :      wind up with bad conversions.  For INTEGER_TYPEs in C, must check
    2806              :      the precision as well, so as to yield correct results for
    2807              :      bit-field types.  C++ does not have these separate bit-field
    2808              :      types, and producing a signed or unsigned variant of an
    2809              :      ENUMERAL_TYPE may cause other problems as well.  */
    2810        18457 :   if (!INTEGRAL_TYPE_P (type)
    2811        18457 :       || TYPE_UNSIGNED (type) == unsignedp)
    2812              :     return type;
    2813              : 
    2814        18457 :   if (BITINT_TYPE_P (type))
    2815            0 :     return build_bitint_type (TYPE_PRECISION (type), unsignedp);
    2816              : 
    2817              : #define TYPE_OK(node)                                                       \
    2818              :   (TYPE_MODE (type) == TYPE_MODE (node)                                     \
    2819              :    && TYPE_PRECISION (type) == TYPE_PRECISION (node))
    2820        18457 :   if (TYPE_OK (signed_char_type_node))
    2821          519 :     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
    2822        17938 :   if (TYPE_OK (integer_type_node))
    2823         7607 :     return unsignedp ? unsigned_type_node : integer_type_node;
    2824        10331 :   if (TYPE_OK (short_integer_type_node))
    2825         4766 :     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
    2826         5565 :   if (TYPE_OK (long_integer_type_node))
    2827            6 :     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
    2828         5559 :   if (TYPE_OK (long_long_integer_type_node))
    2829            0 :     return (unsignedp
    2830            0 :             ? long_long_unsigned_type_node
    2831            0 :             : long_long_integer_type_node);
    2832              : 
    2833        11091 :   for (i = 0; i < NUM_INT_N_ENTS; i ++)
    2834         5559 :     if (int_n_enabled_p[i]
    2835         5559 :         && TYPE_MODE (type) == int_n_data[i].m
    2836         5586 :         && TYPE_PRECISION (type) == int_n_data[i].bitsize)
    2837           27 :         return unsignedp
    2838           27 :           ? int_n_trees[i].unsigned_type
    2839           27 :           : int_n_trees[i].signed_type;
    2840              : 
    2841              : #if HOST_BITS_PER_WIDE_INT >= 64
    2842         5532 :   if (TYPE_OK (intTI_type_node))
    2843            0 :     return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
    2844              : #endif
    2845         5532 :   if (TYPE_OK (intDI_type_node))
    2846            0 :     return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
    2847         5532 :   if (TYPE_OK (intSI_type_node))
    2848            0 :     return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
    2849         5532 :   if (TYPE_OK (intHI_type_node))
    2850            0 :     return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
    2851         5532 :   if (TYPE_OK (intQI_type_node))
    2852            0 :     return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
    2853              : 
    2854              : #undef GIMPLE_FIXED_TYPES
    2855              : #undef GIMPLE_FIXED_MODE_TYPES
    2856              : #undef GIMPLE_FIXED_TYPES_SAT
    2857              : #undef GIMPLE_FIXED_MODE_TYPES_SAT
    2858              : #undef TYPE_OK
    2859              : 
    2860         5532 :   return build_nonstandard_integer_type (TYPE_PRECISION (type), unsignedp);
    2861              : }
    2862              : 
    2863              : 
    2864              : /* Return an unsigned type the same as TYPE in other respects.  */
    2865              : 
    2866              : tree
    2867            0 : gimple_unsigned_type (tree type)
    2868              : {
    2869            0 :   return gimple_signed_or_unsigned_type (true, type);
    2870              : }
    2871              : 
    2872              : 
    2873              : /* Return a signed type the same as TYPE in other respects.  */
    2874              : 
    2875              : tree
    2876       740524 : gimple_signed_type (tree type)
    2877              : {
    2878       740524 :   return gimple_signed_or_unsigned_type (false, type);
    2879              : }
    2880              : 
    2881              : 
    2882              : /* Return the typed-based alias set for T, which may be an expression
    2883              :    or a type.  Return -1 if we don't do anything special.  */
    2884              : 
    2885              : alias_set_type
    2886      9385312 : gimple_get_alias_set (tree t)
    2887              : {
    2888              :   /* That's all the expressions we handle specially.  */
    2889      9385312 :   if (!TYPE_P (t))
    2890              :     return -1;
    2891              : 
    2892              :   /* For convenience, follow the C standard when dealing with
    2893              :      character types.  Any object may be accessed via an lvalue that
    2894              :      has character type.  */
    2895      2711794 :   if (t == char_type_node
    2896      2120937 :       || t == signed_char_type_node
    2897      2120937 :       || t == unsigned_char_type_node)
    2898              :     return 0;
    2899              : 
    2900              :   /* Allow aliasing between signed and unsigned variants of the same
    2901              :      type.  We treat the signed variant as canonical.  BITINT_TYPEs
    2902              :      are handled by canonical type merging.  */
    2903      2120937 :   if (TREE_CODE (t) == INTEGER_TYPE && TYPE_UNSIGNED (t))
    2904              :     {
    2905       739616 :       tree t1 = gimple_signed_type (t);
    2906              : 
    2907              :       /* t1 == t can happen for boolean nodes which are always unsigned.  */
    2908       739616 :       if (t1 != t)
    2909       739616 :         return get_alias_set (t1);
    2910              :     }
    2911              : 
    2912              :   /* Allow aliasing between enumeral types and the underlying
    2913              :      integer type.  This is required for C since those are
    2914              :      compatible types.  */
    2915      1381321 :   else if (TREE_CODE (t) == ENUMERAL_TYPE)
    2916              :     {
    2917            0 :       if (BITINT_TYPE_P (t))
    2918            0 :         return get_alias_set (TREE_TYPE (t));
    2919              : 
    2920            0 :       tree t1 = lang_hooks.types.type_for_size (tree_to_uhwi (TYPE_SIZE (t)),
    2921              :                                                 false /* short-cut above */);
    2922            0 :       return get_alias_set (t1);
    2923              :     }
    2924              : 
    2925              :   return -1;
    2926              : }
    2927              : 
    2928              : 
    2929              : /* Return true when STMTs arguments and return value match those of FNDECL,
    2930              :    a decl of a builtin function.  */
    2931              : 
    2932              : bool
    2933    300128251 : gimple_builtin_call_types_compatible_p (const gimple *stmt, tree fndecl)
    2934              : {
    2935    300128251 :   gcc_checking_assert (DECL_BUILT_IN_CLASS (fndecl) != NOT_BUILT_IN);
    2936              : 
    2937    300128251 :   if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
    2938    297742365 :     if (tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl)))
    2939    300128251 :       fndecl = decl;
    2940              : 
    2941    300128251 :   tree ret = gimple_call_lhs (stmt);
    2942    300128251 :   if (ret
    2943    484715996 :       && !useless_type_conversion_p (TREE_TYPE (ret),
    2944    184587745 :                                      TREE_TYPE (TREE_TYPE (fndecl))))
    2945              :     return false;
    2946              : 
    2947    300106268 :   tree targs = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
    2948    300106268 :   unsigned nargs = gimple_call_num_args (stmt);
    2949   1231586283 :   for (unsigned i = 0; i < nargs; ++i)
    2950              :     {
    2951              :       /* Variadic args follow.  */
    2952    665460404 :       if (!targs)
    2953              :         return true;
    2954    636591664 :       tree arg = gimple_call_arg (stmt, i);
    2955    636591664 :       tree type = TREE_VALUE (targs);
    2956    636591664 :       if (!useless_type_conversion_p (type, TREE_TYPE (arg)))
    2957              :         return false;
    2958    631373747 :       targs = TREE_CHAIN (targs);
    2959              :     }
    2960    531214360 :   if (targs && !VOID_TYPE_P (TREE_VALUE (targs)))
    2961         7153 :     return false;
    2962              :   return true;
    2963              : }
    2964              : 
    2965              : /* Return true when STMT is operator a replaceable delete call.  */
    2966              : 
    2967              : bool
    2968      2509380 : gimple_call_operator_delete_p (const gcall *stmt)
    2969              : {
    2970      2509380 :   tree fndecl;
    2971              : 
    2972      2509380 :   if ((fndecl = gimple_call_fndecl (stmt)) != NULL_TREE)
    2973      2509380 :     return DECL_IS_OPERATOR_DELETE_P (fndecl);
    2974              :   return false;
    2975              : }
    2976              : 
    2977              : /* Return true when STMT is builtins call.  */
    2978              : 
    2979              : bool
    2980     71517404 : gimple_call_builtin_p (const gimple *stmt)
    2981              : {
    2982     71517404 :   tree fndecl;
    2983     71517404 :   if (is_gimple_call (stmt)
    2984     22393417 :       && (fndecl = gimple_call_fndecl (stmt)) != NULL_TREE
    2985     92626319 :       && DECL_BUILT_IN_CLASS (fndecl) != NOT_BUILT_IN)
    2986      5016245 :     return gimple_builtin_call_types_compatible_p (stmt, fndecl);
    2987              :   return false;
    2988              : }
    2989              : 
    2990              : /* Return true when STMT is builtins call to CLASS.  */
    2991              : 
    2992              : bool
    2993   1061411637 : gimple_call_builtin_p (const gimple *stmt, enum built_in_class klass)
    2994              : {
    2995   1061411637 :   tree fndecl;
    2996   1061411637 :   if (is_gimple_call (stmt)
    2997    804717515 :       && (fndecl = gimple_call_fndecl (stmt)) != NULL_TREE
    2998   1827866753 :       && DECL_BUILT_IN_CLASS (fndecl) == klass)
    2999    202741037 :     return gimple_builtin_call_types_compatible_p (stmt, fndecl);
    3000              :   return false;
    3001              : }
    3002              : 
    3003              : /* Return true when STMT is builtins call to CODE of CLASS.  */
    3004              : 
    3005              : bool
    3006   3017027219 : gimple_call_builtin_p (const gimple *stmt, enum built_in_function code)
    3007              : {
    3008   3017027219 :   tree fndecl;
    3009   3017027219 :   if (is_gimple_call (stmt)
    3010    902130721 :       && (fndecl = gimple_call_fndecl (stmt)) != NULL_TREE
    3011   3875648963 :       && fndecl_built_in_p (fndecl, code))
    3012      2657281 :     return gimple_builtin_call_types_compatible_p (stmt, fndecl);
    3013              :   return false;
    3014              : }
    3015              : 
    3016              : /* If CALL is a call to a combined_fn (i.e. an internal function or
    3017              :    a normal built-in function), return its code, otherwise return
    3018              :    CFN_LAST.  */
    3019              : 
    3020              : combined_fn
    3021    191195878 : gimple_call_combined_fn (const gimple *stmt)
    3022              : {
    3023    191195878 :   if (const gcall *call = dyn_cast <const gcall *> (stmt))
    3024              :     {
    3025    190989419 :       if (gimple_call_internal_p (call))
    3026      9170123 :         return as_combined_fn (gimple_call_internal_fn (call));
    3027              : 
    3028    181819296 :       tree fndecl = gimple_call_fndecl (stmt);
    3029    181819296 :       if (fndecl
    3030    175344651 :           && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
    3031    253870654 :           && gimple_builtin_call_types_compatible_p (stmt, fndecl))
    3032     71454640 :         return as_combined_fn (DECL_FUNCTION_CODE (fndecl));
    3033              :     }
    3034              :   return CFN_LAST;
    3035              : }
    3036              : 
    3037              : /* Return true if STMT clobbers memory.  STMT is required to be a
    3038              :    GIMPLE_ASM.  */
    3039              : 
    3040              : bool
    3041     10868420 : gimple_asm_clobbers_memory_p (const gasm *stmt)
    3042              : {
    3043     10868420 :   unsigned i;
    3044              : 
    3045     14944041 :   for (i = 0; i < gimple_asm_nclobbers (stmt); i++)
    3046              :     {
    3047      8510758 :       tree op = gimple_asm_clobber_op (stmt, i);
    3048      8510758 :       if (strcmp (TREE_STRING_POINTER (TREE_VALUE (op)), "memory") == 0)
    3049              :         return true;
    3050              :     }
    3051              : 
    3052              :   /* Non-empty basic ASM implicitly clobbers memory.  */
    3053      6433283 :   if (gimple_asm_basic_p (stmt) && strlen (gimple_asm_string (stmt)) != 0)
    3054        82324 :     return true;
    3055              : 
    3056              :   return false;
    3057              : }
    3058              : 
    3059              : /* Dump bitmap SET (assumed to contain VAR_DECLs) to FILE.  */
    3060              : 
    3061              : void
    3062         5426 : dump_decl_set (FILE *file, const_bitmap set)
    3063              : {
    3064         5426 :   if (set)
    3065              :     {
    3066         5426 :       bitmap_iterator bi;
    3067         5426 :       unsigned i;
    3068              : 
    3069         5426 :       fprintf (file, "{ ");
    3070              : 
    3071        22569 :       EXECUTE_IF_SET_IN_BITMAP (set, 0, i, bi)
    3072              :         {
    3073        17143 :           fprintf (file, "D.%u", i);
    3074        17143 :           fprintf (file, " ");
    3075              :         }
    3076              : 
    3077         5426 :       fprintf (file, "}");
    3078              :     }
    3079              :   else
    3080            0 :     fprintf (file, "NIL");
    3081         5426 : }
    3082              : 
    3083              : /* Return true when CALL is a call stmt that definitely doesn't
    3084              :    free any memory or makes it unavailable otherwise.  */
    3085              : bool
    3086     10201737 : nonfreeing_call_p (const gimple *call)
    3087              : {
    3088     10201737 :   if (gimple_call_builtin_p (call, BUILT_IN_NORMAL)
    3089     10201737 :       && gimple_call_flags (call) & ECF_LEAF)
    3090      4460581 :     switch (DECL_FUNCTION_CODE (gimple_call_fndecl (call)))
    3091              :       {
    3092              :         /* Just in case these become ECF_LEAF in the future.  */
    3093              :         case BUILT_IN_FREE:
    3094              :         case BUILT_IN_TM_FREE:
    3095              :         case BUILT_IN_REALLOC:
    3096              :         case BUILT_IN_STACK_RESTORE:
    3097              :         case BUILT_IN_GOMP_FREE:
    3098              :         case BUILT_IN_GOMP_REALLOC:
    3099              :           return false;
    3100      4245553 :         default:
    3101      4245553 :           return true;
    3102              :       }
    3103      5741156 :   else if (gimple_call_internal_p (call))
    3104       790941 :     switch (gimple_call_internal_fn (call))
    3105              :       {
    3106              :       case IFN_ABNORMAL_DISPATCHER:
    3107              :         return true;
    3108        35673 :       case IFN_ASAN_MARK:
    3109        35673 :         return tree_to_uhwi (gimple_call_arg (call, 0)) == ASAN_MARK_UNPOISON;
    3110       749096 :       default:
    3111       749096 :         if (gimple_call_flags (call) & ECF_LEAF)
    3112              :           return true;
    3113       148466 :         return false;
    3114              :       }
    3115              : 
    3116      4950215 :   tree fndecl = gimple_call_fndecl (call);
    3117      4950215 :   if (!fndecl)
    3118              :     return false;
    3119      4788370 :   struct cgraph_node *n = cgraph_node::get (fndecl);
    3120      4788370 :   if (!n)
    3121              :     return false;
    3122      4786992 :   enum availability availability;
    3123      4786992 :   n = n->function_symbol (&availability);
    3124      4786992 :   if (!n || availability <= AVAIL_INTERPOSABLE)
    3125              :     return false;
    3126      1151661 :   return n->nonfreeing_fn;
    3127              : }
    3128              : 
    3129              : /* Return true when CALL is a call stmt that definitely need not
    3130              :    be considered to be a memory barrier.  */
    3131              : bool
    3132      1660377 : nonbarrier_call_p (const gimple *call)
    3133              : {
    3134      1660377 :   if (gimple_call_flags (call) & (ECF_PURE | ECF_CONST))
    3135       634638 :     return true;
    3136              :   /* Should extend this to have a nonbarrier_fn flag, just as above in
    3137              :      the nonfreeing case.  */
    3138              :   return false;
    3139              : }
    3140              : 
    3141              : /* Callback for walk_stmt_load_store_ops.
    3142              : 
    3143              :    Return TRUE if OP will dereference the tree stored in DATA, FALSE
    3144              :    otherwise.
    3145              : 
    3146              :    This routine only makes a superficial check for a dereference.  Thus
    3147              :    it must only be used if it is safe to return a false negative.  */
    3148              : static bool
    3149     78531716 : check_loadstore (gimple *stmt, tree op, tree, void *data)
    3150              : {
    3151    157063432 :   if (TREE_CODE (op) == MEM_REF
    3152     78531716 :       || (TREE_CODE (op) == TARGET_MEM_REF
    3153      1388204 :           && !TMR_INDEX2 (op)
    3154      1371733 :           && (!TMR_INDEX (op)
    3155       653994 :               || (TMR_STEP (op)
    3156       593566 :                   && expr_not_equal_to (TMR_STEP (op),
    3157     79125282 :                                         wi::one (TYPE_PRECISION (TREE_TYPE
    3158              :                                                         (TMR_STEP (op)))),
    3159              :                                         stmt)))))
    3160              :     {
    3161              :       /* Some address spaces may legitimately dereference zero.  */
    3162     40536395 :       addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (op));
    3163     40536395 :       if (targetm.addr_space.zero_address_valid (as))
    3164              :         return false;
    3165              : 
    3166     40535254 :       return operand_equal_p (TREE_OPERAND (op, 0), (tree)data, 0);
    3167              :     }
    3168              :   return false;
    3169              : }
    3170              : 
    3171              : 
    3172              : /* Return true if OP can be inferred to be non-NULL after STMT executes,
    3173              :    either by using a pointer dereference or attributes.  */
    3174              : bool
    3175            0 : infer_nonnull_range (gimple *stmt, tree op)
    3176              : {
    3177            0 :   return (infer_nonnull_range_by_dereference (stmt, op)
    3178            0 :           || infer_nonnull_range_by_attribute (stmt, op));
    3179              : }
    3180              : 
    3181              : /* Return true if OP can be inferred to be non-NULL after STMT
    3182              :    executes by using a pointer dereference.  */
    3183              : bool
    3184    348016372 : infer_nonnull_range_by_dereference (gimple *stmt, tree op)
    3185              : {
    3186              :   /* We can only assume that a pointer dereference will yield
    3187              :      non-NULL if -fdelete-null-pointer-checks is enabled.  */
    3188    348016372 :   if (!flag_delete_null_pointer_checks
    3189    347802018 :       || !POINTER_TYPE_P (TREE_TYPE (op))
    3190    347802018 :       || gimple_code (stmt) == GIMPLE_ASM
    3191    695389216 :       || gimple_clobber_p (stmt))
    3192              :     return false;
    3193              : 
    3194    340044176 :   if (walk_stmt_load_store_ops (stmt, (void *)op,
    3195              :                                 check_loadstore, check_loadstore))
    3196              :     return true;
    3197              : 
    3198              :   return false;
    3199              : }
    3200              : 
    3201              : /* Return true if OP can be inferred to be a non-NULL after STMT
    3202              :    executes by using attributes.  If OP2 and OP3 are non-NULL and
    3203              :    nonnull_if_nonzero is the only attribute implying OP being non-NULL
    3204              :    and the corresponding argument(s) aren't non-zero INTEGER_CST, set *OP2
    3205              :    and *OP3 to the corresponding arguments and return true (in that case
    3206              :    returning true doesn't mean OP can be unconditionally inferred to be
    3207              :    non-NULL, but conditionally).  */
    3208              : bool
    3209     78285919 : infer_nonnull_range_by_attribute (const gimple *stmt, tree op, tree *op2,
    3210              :                                   tree *op3)
    3211              : {
    3212     78285919 :   if (op2)
    3213              :     {
    3214         3934 :       *op2 = NULL_TREE;
    3215         3934 :       *op3 = NULL_TREE;
    3216              :     }
    3217              : 
    3218              :   /* We can only assume that a pointer dereference will yield
    3219              :      non-NULL if -fdelete-null-pointer-checks is enabled.  */
    3220     78285919 :   if (!flag_delete_null_pointer_checks
    3221     78257152 :       || !POINTER_TYPE_P (TREE_TYPE (op))
    3222    156543071 :       || gimple_code (stmt) == GIMPLE_ASM)
    3223              :     return false;
    3224              : 
    3225     78206145 :   if (is_gimple_call (stmt) && !gimple_call_internal_p (stmt))
    3226              :     {
    3227      4509863 :       tree fntype = gimple_call_fntype (stmt);
    3228      4509863 :       tree attrs = TYPE_ATTRIBUTES (fntype);
    3229      4608839 :       for (; attrs; attrs = TREE_CHAIN (attrs))
    3230              :         {
    3231      1171462 :           attrs = lookup_attribute ("nonnull", attrs);
    3232              : 
    3233              :           /* If "nonnull" wasn't specified, we know nothing about
    3234              :              the argument, unless "nonnull_if_nonzero" attribute is
    3235              :              present.  */
    3236      1171462 :           if (attrs == NULL_TREE)
    3237              :             break;
    3238              : 
    3239              :           /* If "nonnull" applies to all the arguments, then ARG
    3240              :              is non-null if it's in the argument list.  */
    3241       257309 :           if (TREE_VALUE (attrs) == NULL_TREE)
    3242              :             {
    3243       460575 :               for (unsigned int i = 0; i < gimple_call_num_args (stmt); i++)
    3244              :                 {
    3245       311056 :                   if (POINTER_TYPE_P (TREE_TYPE (gimple_call_arg (stmt, i)))
    3246       303330 :                       && operand_equal_p (op, gimple_call_arg (stmt, i), 0))
    3247              :                     return true;
    3248              :                 }
    3249              :               return false;
    3250              :             }
    3251              : 
    3252              :           /* Now see if op appears in the nonnull list.  */
    3253       249924 :           for (tree t = TREE_VALUE (attrs); t; t = TREE_CHAIN (t))
    3254              :             {
    3255       150948 :               unsigned int idx = TREE_INT_CST_LOW (TREE_VALUE (t)) - 1;
    3256       150948 :               if (idx < gimple_call_num_args (stmt))
    3257              :                 {
    3258       150947 :                   tree arg = gimple_call_arg (stmt, idx);
    3259       150947 :                   if (operand_equal_p (op, arg, 0))
    3260              :                     return true;
    3261              :                 }
    3262              :             }
    3263              :         }
    3264              : 
    3265      4351530 :       for (attrs = TYPE_ATTRIBUTES (fntype);
    3266      4549482 :            (attrs = lookup_attribute ("nonnull_if_nonzero", attrs));
    3267       197952 :            attrs = TREE_CHAIN (attrs))
    3268              :         {
    3269       198765 :           tree args = TREE_VALUE (attrs);
    3270       198765 :           unsigned int idx = TREE_INT_CST_LOW (TREE_VALUE (args)) - 1;
    3271       198765 :           unsigned int idx2
    3272       198765 :             = TREE_INT_CST_LOW (TREE_VALUE (TREE_CHAIN (args))) - 1;
    3273       198765 :           unsigned int idx3 = idx2;
    3274       198765 :           if (tree chain2 = TREE_CHAIN (TREE_CHAIN (args)))
    3275         4356 :             idx3 = TREE_INT_CST_LOW (TREE_VALUE (chain2)) - 1;
    3276       198765 :           if (idx < gimple_call_num_args (stmt)
    3277       198753 :               && idx2 < gimple_call_num_args (stmt)
    3278       198742 :               && idx3 < gimple_call_num_args (stmt)
    3279       397507 :               && operand_equal_p (op, gimple_call_arg (stmt, idx), 0))
    3280              :             {
    3281          813 :               tree arg2 = gimple_call_arg (stmt, idx2);
    3282          813 :               tree arg3 = gimple_call_arg (stmt, idx3);
    3283         1626 :               if (!INTEGRAL_TYPE_P (TREE_TYPE (arg2))
    3284         1626 :                   || !INTEGRAL_TYPE_P (TREE_TYPE (arg3)))
    3285              :                 return false;
    3286          813 :               if (integer_nonzerop (arg2) && integer_nonzerop (arg3))
    3287              :                 return true;
    3288          591 :               if (integer_zerop (arg2) || integer_zerop (arg3))
    3289              :                 return false;
    3290          501 :               if (op2)
    3291              :                 {
    3292              :                   /* This case is meant for ubsan instrumentation.
    3293              :                      The caller can check at runtime if *OP2 and *OP3 are
    3294              :                      non-zero and OP is null.  */
    3295          132 :                   *op2 = arg2;
    3296          132 :                   *op3 = arg3;
    3297          132 :                   return true;
    3298              :                 }
    3299          369 :               return tree_expr_nonzero_p (arg2) && tree_expr_nonzero_p (arg3);
    3300              :             }
    3301              :         }
    3302              :     }
    3303              : 
    3304              :   /* If this function is marked as returning non-null, then we can
    3305              :      infer OP is non-null if it is used in the return statement.  */
    3306     78046999 :   if (const greturn *return_stmt = dyn_cast <const greturn *> (stmt))
    3307       970087 :     if (gimple_return_retval (return_stmt)
    3308       558603 :         && operand_equal_p (gimple_return_retval (return_stmt), op, 0)
    3309      1064996 :         && lookup_attribute ("returns_nonnull",
    3310        94909 :                              TYPE_ATTRIBUTES (TREE_TYPE (current_function_decl))))
    3311              :       return true;
    3312              : 
    3313              :   return false;
    3314              : }
    3315              : 
    3316              : /* Compare two case labels.  Because the front end should already have
    3317              :    made sure that case ranges do not overlap, it is enough to only compare
    3318              :    the CASE_LOW values of each case label.  */
    3319              : 
    3320              : static int
    3321     43857471 : compare_case_labels (const void *p1, const void *p2)
    3322              : {
    3323     43857471 :   const_tree const case1 = *(const_tree const*)p1;
    3324     43857471 :   const_tree const case2 = *(const_tree const*)p2;
    3325              : 
    3326              :   /* The 'default' case label always goes first.  */
    3327     43857471 :   if (!CASE_LOW (case1))
    3328              :     return -1;
    3329     43857471 :   else if (!CASE_LOW (case2))
    3330              :     return 1;
    3331              :   else
    3332     43857471 :     return tree_int_cst_compare (CASE_LOW (case1), CASE_LOW (case2));
    3333              : }
    3334              : 
    3335              : /* Sort the case labels in LABEL_VEC in place in ascending order.  */
    3336              : 
    3337              : void
    3338        72682 : sort_case_labels (vec<tree> &label_vec)
    3339              : {
    3340        72682 :   label_vec.qsort (compare_case_labels);
    3341        72682 : }
    3342              : 
    3343              : /* Prepare a vector of case labels to be used in a GIMPLE_SWITCH statement.
    3344              : 
    3345              :    LABELS is a vector that contains all case labels to look at.
    3346              : 
    3347              :    INDEX_TYPE is the type of the switch index expression.  Case labels
    3348              :    in LABELS are discarded if their values are not in the value range
    3349              :    covered by INDEX_TYPE.  The remaining case label values are folded
    3350              :    to INDEX_TYPE.
    3351              : 
    3352              :    If a default case exists in LABELS, it is removed from LABELS and
    3353              :    returned in DEFAULT_CASEP.  If no default case exists, but the
    3354              :    case labels already cover the whole range of INDEX_TYPE, a default
    3355              :    case is returned pointing to one of the existing case labels.
    3356              :    Otherwise DEFAULT_CASEP is set to NULL_TREE.
    3357              : 
    3358              :    DEFAULT_CASEP may be NULL, in which case the above comment doesn't
    3359              :    apply and no action is taken regardless of whether a default case is
    3360              :    found or not.  */
    3361              : 
    3362              : void
    3363        63089 : preprocess_case_label_vec_for_gimple (vec<tree> &labels,
    3364              :                                       tree index_type,
    3365              :                                       tree *default_casep)
    3366              : {
    3367        63089 :   tree min_value, max_value;
    3368        63089 :   tree default_case = NULL_TREE;
    3369        63089 :   size_t i, len;
    3370              : 
    3371        63089 :   i = 0;
    3372        63089 :   min_value = TYPE_MIN_VALUE (index_type);
    3373        63089 :   max_value = TYPE_MAX_VALUE (index_type);
    3374      1163308 :   while (i < labels.length ())
    3375              :     {
    3376      1100219 :       tree elt = labels[i];
    3377      1100219 :       tree low = CASE_LOW (elt);
    3378      1100219 :       tree high = CASE_HIGH (elt);
    3379      1100219 :       bool remove_element = false;
    3380              : 
    3381      1100219 :       if (low)
    3382              :         {
    3383      1064159 :           gcc_checking_assert (TREE_CODE (low) == INTEGER_CST);
    3384      1064159 :           gcc_checking_assert (!high || TREE_CODE (high) == INTEGER_CST);
    3385              : 
    3386              :           /* This is a non-default case label, i.e. it has a value.
    3387              : 
    3388              :              See if the case label is reachable within the range of
    3389              :              the index type.  Remove out-of-range case values.  Turn
    3390              :              case ranges into a canonical form (high > low strictly)
    3391              :              and convert the case label values to the index type.
    3392              : 
    3393              :              NB: The type of gimple_switch_index() may be the promoted
    3394              :              type, but the case labels retain the original type.  */
    3395              : 
    3396        12826 :           if (high)
    3397              :             {
    3398              :               /* This is a case range.  Discard empty ranges.
    3399              :                  If the bounds or the range are equal, turn this
    3400              :                  into a simple (one-value) case.  */
    3401        12826 :               int cmp = tree_int_cst_compare (high, low);
    3402        12826 :               if (cmp < 0)
    3403              :                 remove_element = true;
    3404        12826 :               else if (cmp == 0)
    3405              :                 high = NULL_TREE;
    3406              :             }
    3407              : 
    3408      1053010 :           if (! high)
    3409              :             {
    3410              :               /* If the simple case value is unreachable, ignore it.  */
    3411      1062482 :               if ((TREE_CODE (min_value) == INTEGER_CST
    3412      1062482 :                    && tree_int_cst_compare (low, min_value) < 0)
    3413      2124921 :                   || (TREE_CODE (max_value) == INTEGER_CST
    3414      1062439 :                       && tree_int_cst_compare (low, max_value) > 0))
    3415              :                 remove_element = true;
    3416              :               else
    3417      1062321 :                 low = fold_convert (index_type, low);
    3418              :             }
    3419              :           else
    3420              :             {
    3421              :               /* If the entire case range is unreachable, ignore it.  */
    3422         1677 :               if ((TREE_CODE (min_value) == INTEGER_CST
    3423         1677 :                    && tree_int_cst_compare (high, min_value) < 0)
    3424         3342 :                   || (TREE_CODE (max_value) == INTEGER_CST
    3425         1665 :                       && tree_int_cst_compare (low, max_value) > 0))
    3426              :                 remove_element = true;
    3427              :               else
    3428              :                 {
    3429              :                   /* If the lower bound is less than the index type's
    3430              :                      minimum value, truncate the range bounds.  */
    3431         1665 :                   if (TREE_CODE (min_value) == INTEGER_CST
    3432         1665 :                       && tree_int_cst_compare (low, min_value) < 0)
    3433              :                     low = min_value;
    3434         1665 :                   low = fold_convert (index_type, low);
    3435              : 
    3436              :                   /* If the upper bound is greater than the index type's
    3437              :                      maximum value, truncate the range bounds.  */
    3438         1665 :                   if (TREE_CODE (max_value) == INTEGER_CST
    3439         1665 :                       && tree_int_cst_compare (high, max_value) > 0)
    3440              :                     high = max_value;
    3441         1665 :                   high = fold_convert (index_type, high);
    3442              : 
    3443              :                   /* We may have folded a case range to a one-value case.  */
    3444         1665 :                   if (tree_int_cst_equal (low, high))
    3445            0 :                     high = NULL_TREE;
    3446              :                 }
    3447              :             }
    3448              : 
    3449      1064159 :           CASE_LOW (elt) = low;
    3450      1064159 :           CASE_HIGH (elt) = high;
    3451              :         }
    3452              :       else
    3453              :         {
    3454        36060 :           gcc_assert (!default_case);
    3455        36060 :           default_case = elt;
    3456              :           /* The default case must be passed separately to the
    3457              :              gimple_build_switch routine.  But if DEFAULT_CASEP
    3458              :              is NULL, we do not remove the default case (it would
    3459              :              be completely lost).  */
    3460        36060 :           if (default_casep)
    3461              :             remove_element = true;
    3462              :         }
    3463              : 
    3464      1064159 :       if (remove_element)
    3465        36233 :         labels.ordered_remove (i);
    3466              :       else
    3467      1063986 :         i++;
    3468              :     }
    3469        63089 :   len = i;
    3470              : 
    3471        63089 :   if (!labels.is_empty ())
    3472        62209 :     sort_case_labels (labels);
    3473              : 
    3474        63089 :   if (default_casep && !default_case)
    3475              :     {
    3476              :       /* If the switch has no default label, add one, so that we jump
    3477              :          around the switch body.  If the labels already cover the whole
    3478              :          range of the switch index_type, add the default label pointing
    3479              :          to one of the existing labels.  */
    3480        15237 :       if (len
    3481        14756 :           && TYPE_MIN_VALUE (index_type)
    3482        14756 :           && TYPE_MAX_VALUE (index_type)
    3483        29993 :           && tree_int_cst_equal (CASE_LOW (labels[0]),
    3484        14756 :                                  TYPE_MIN_VALUE (index_type)))
    3485              :         {
    3486         4442 :           tree low, high = CASE_HIGH (labels[len - 1]);
    3487         4442 :           if (!high)
    3488         4399 :             high = CASE_LOW (labels[len - 1]);
    3489         4442 :           if (tree_int_cst_equal (high, TYPE_MAX_VALUE (index_type)))
    3490              :             {
    3491           62 :               tree widest_label = labels[0];
    3492          131 :               for (i = 1; i < len; i++)
    3493              :                 {
    3494           83 :                   high = CASE_LOW (labels[i]);
    3495           83 :                   low = CASE_HIGH (labels[i - 1]);
    3496           83 :                   if (!low)
    3497           53 :                     low = CASE_LOW (labels[i - 1]);
    3498              : 
    3499           83 :                   if (CASE_HIGH (labels[i]) != NULL_TREE
    3500          114 :                       && (CASE_HIGH (widest_label) == NULL_TREE
    3501           26 :                           || (wi::gtu_p
    3502           52 :                               (wi::to_wide (CASE_HIGH (labels[i]))
    3503           78 :                                - wi::to_wide (CASE_LOW (labels[i])),
    3504           26 :                                wi::to_wide (CASE_HIGH (widest_label))
    3505          161 :                                - wi::to_wide (CASE_LOW (widest_label))))))
    3506           17 :                     widest_label = labels[i];
    3507              : 
    3508           83 :                   if (wi::to_wide (low) + 1 != wi::to_wide (high))
    3509              :                     break;
    3510              :                 }
    3511           62 :               if (i == len)
    3512              :                 {
    3513              :                   /* Designate the label with the widest range to be the
    3514              :                      default label.  */
    3515           48 :                   tree label = CASE_LABEL (widest_label);
    3516           48 :                   default_case = build_case_label (NULL_TREE, NULL_TREE,
    3517              :                                                    label);
    3518              :                 }
    3519              :             }
    3520              :         }
    3521              :     }
    3522              : 
    3523        63089 :   if (default_casep)
    3524        51297 :     *default_casep = default_case;
    3525        63089 : }
    3526              : 
    3527              : /* Set the location of all statements in SEQ to LOC.  */
    3528              : 
    3529              : void
    3530      1083539 : gimple_seq_set_location (gimple_seq seq, location_t loc)
    3531              : {
    3532      2203445 :   for (gimple_stmt_iterator i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
    3533      1119906 :     gimple_set_location (gsi_stmt (i), loc);
    3534      1083539 : }
    3535              : 
    3536              : /* Release SSA_NAMEs in SEQ as well as the GIMPLE statements.  */
    3537              : 
    3538              : void
    3539    804529938 : gimple_seq_discard (gimple_seq seq)
    3540              : {
    3541    804529938 :   gimple_stmt_iterator gsi;
    3542              : 
    3543    805029720 :   for (gsi = gsi_start (seq); !gsi_end_p (gsi); )
    3544              :     {
    3545       313189 :       gimple *stmt = gsi_stmt (gsi);
    3546       313189 :       gsi_remove (&gsi, true);
    3547       313189 :       release_defs (stmt);
    3548       313189 :       ggc_free (stmt);
    3549              :     }
    3550    804529938 : }
    3551              : 
    3552              : /* See if STMT now calls function that takes no parameters and if so, drop
    3553              :    call arguments.  This is used when devirtualization machinery redirects
    3554              :    to __builtin_unreachable or __cxa_pure_virtual.  */
    3555              : 
    3556              : void
    3557      1150892 : maybe_remove_unused_call_args (struct function *fn, gimple *stmt)
    3558              : {
    3559      1150892 :   tree decl = gimple_call_fndecl (stmt);
    3560      1150892 :   if (TYPE_ARG_TYPES (TREE_TYPE (decl))
    3561      1150054 :       && TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl))) == void_type_node
    3562      1390390 :       && gimple_call_num_args (stmt))
    3563              :     {
    3564       123342 :       gimple_set_num_ops (stmt, 3);
    3565       123342 :       update_stmt_fn (fn, stmt);
    3566              :     }
    3567      1150892 : }
    3568              : 
    3569              : /* Return false if STMT will likely expand to real function call.  */
    3570              : 
    3571              : bool
    3572      3421262 : gimple_inexpensive_call_p (const gcall *stmt)
    3573              : {
    3574      3421262 :   if (gimple_call_internal_p (stmt))
    3575              :     return true;
    3576      3359845 :   tree decl = gimple_call_fndecl (stmt);
    3577      3359845 :   if (decl && is_inexpensive_builtin (decl))
    3578              :     return true;
    3579              :   return false;
    3580              : }
    3581              : 
    3582              : /* Return a non-artificial location for STMT.  If STMT does not have
    3583              :    location information, get the location from EXPR.  */
    3584              : 
    3585              : location_t
    3586       118660 : gimple_or_expr_nonartificial_location (const gimple *stmt, tree expr)
    3587              : {
    3588       118660 :   location_t loc = gimple_nonartificial_location (stmt);
    3589       118660 :   if (loc == UNKNOWN_LOCATION && EXPR_HAS_LOCATION (expr))
    3590           46 :     loc = tree_nonartificial_location (expr);
    3591       118660 :   return expansion_point_location_if_in_system_header (loc);
    3592              : }
    3593              : 
    3594              : 
    3595              : #if CHECKING_P
    3596              : 
    3597              : namespace selftest {
    3598              : 
    3599              : /* Selftests for core gimple structures.  */
    3600              : 
    3601              : /* Verify that STMT is pretty-printed as EXPECTED.
    3602              :    Helper function for selftests.  */
    3603              : 
    3604              : static void
    3605           20 : verify_gimple_pp (const char *expected, gimple *stmt)
    3606              : {
    3607           20 :   pretty_printer pp;
    3608           20 :   pp_gimple_stmt_1 (&pp, stmt, 0 /* spc */, TDF_NONE /* flags */);
    3609           20 :   ASSERT_STREQ (expected, pp_formatted_text (&pp));
    3610           20 : }
    3611              : 
    3612              : /* Build a GIMPLE_ASSIGN equivalent to
    3613              :      tmp = 5;
    3614              :    and verify various properties of it.  */
    3615              : 
    3616              : static void
    3617            4 : test_assign_single ()
    3618              : {
    3619            4 :   tree type = integer_type_node;
    3620            4 :   tree lhs = build_decl (UNKNOWN_LOCATION, VAR_DECL,
    3621              :                          get_identifier ("tmp"),
    3622              :                          type);
    3623            4 :   tree rhs = build_int_cst (type, 5);
    3624            4 :   gassign *stmt = gimple_build_assign (lhs, rhs);
    3625            4 :   verify_gimple_pp ("tmp = 5;", stmt);
    3626              : 
    3627            4 :   ASSERT_TRUE (is_gimple_assign (stmt));
    3628            4 :   ASSERT_EQ (lhs, gimple_assign_lhs (stmt));
    3629            4 :   ASSERT_EQ (lhs, gimple_get_lhs (stmt));
    3630            4 :   ASSERT_EQ (rhs, gimple_assign_rhs1 (stmt));
    3631            4 :   ASSERT_EQ (NULL, gimple_assign_rhs2 (stmt));
    3632            4 :   ASSERT_EQ (NULL, gimple_assign_rhs3 (stmt));
    3633            4 :   ASSERT_TRUE (gimple_assign_single_p (stmt));
    3634            8 :   ASSERT_EQ (INTEGER_CST, gimple_assign_rhs_code (stmt));
    3635            4 : }
    3636              : 
    3637              : /* Build a GIMPLE_ASSIGN equivalent to
    3638              :      tmp = a * b;
    3639              :    and verify various properties of it.  */
    3640              : 
    3641              : static void
    3642            4 : test_assign_binop ()
    3643              : {
    3644            4 :   tree type = integer_type_node;
    3645            4 :   tree lhs = build_decl (UNKNOWN_LOCATION, VAR_DECL,
    3646              :                          get_identifier ("tmp"),
    3647              :                          type);
    3648            4 :   tree a = build_decl (UNKNOWN_LOCATION, VAR_DECL,
    3649              :                        get_identifier ("a"),
    3650              :                        type);
    3651            4 :   tree b = build_decl (UNKNOWN_LOCATION, VAR_DECL,
    3652              :                        get_identifier ("b"),
    3653              :                        type);
    3654            4 :   gassign *stmt = gimple_build_assign (lhs, MULT_EXPR, a, b);
    3655            4 :   verify_gimple_pp ("tmp = a * b;", stmt);
    3656              : 
    3657            4 :   ASSERT_TRUE (is_gimple_assign (stmt));
    3658            4 :   ASSERT_EQ (lhs, gimple_assign_lhs (stmt));
    3659            4 :   ASSERT_EQ (lhs, gimple_get_lhs (stmt));
    3660            4 :   ASSERT_EQ (a, gimple_assign_rhs1 (stmt));
    3661            8 :   ASSERT_EQ (b, gimple_assign_rhs2 (stmt));
    3662            4 :   ASSERT_EQ (NULL, gimple_assign_rhs3 (stmt));
    3663            4 :   ASSERT_FALSE (gimple_assign_single_p (stmt));
    3664            4 :   ASSERT_EQ (MULT_EXPR, gimple_assign_rhs_code (stmt));
    3665            4 : }
    3666              : 
    3667              : /* Verify that GIMPLE trap queries distinguish a register definition and a
    3668              :    trapping store from their nontrapping right-hand sides.  */
    3669              : 
    3670              : static void
    3671            4 : test_could_trap ()
    3672              : {
    3673            4 :   tree reg_lhs = build_decl (UNKNOWN_LOCATION, VAR_DECL,
    3674              :                              get_identifier ("readonly_reg"),
    3675              :                              integer_type_node);
    3676            4 :   TREE_READONLY (reg_lhs) = 1;
    3677            4 :   gassign *stmt = gimple_build_assign (reg_lhs, integer_one_node);
    3678              : 
    3679            4 :   ASSERT_FALSE (gimple_store_p (stmt));
    3680            4 :   ASSERT_FALSE (gimple_could_trap_p (stmt));
    3681            4 :   ASSERT_FALSE (gimple_assign_rhs_could_trap_p (stmt));
    3682              : 
    3683            4 :   tree mem_lhs = build_decl (UNKNOWN_LOCATION, VAR_DECL,
    3684              :                              get_identifier ("readonly_mem"),
    3685              :                              integer_type_node);
    3686            4 :   TREE_READONLY (mem_lhs) = 1;
    3687            4 :   TREE_STATIC (mem_lhs) = 1;
    3688            4 :   TREE_ADDRESSABLE (mem_lhs) = 1;
    3689            4 :   stmt = gimple_build_assign (mem_lhs, integer_one_node);
    3690              : 
    3691            4 :   ASSERT_TRUE (gimple_store_p (stmt));
    3692            4 :   ASSERT_TRUE (gimple_could_trap_p (stmt));
    3693            4 :   ASSERT_FALSE (gimple_assign_rhs_could_trap_p (stmt));
    3694              : 
    3695            4 :   tree record_type = make_node (RECORD_TYPE);
    3696            4 :   tree field = build_decl (UNKNOWN_LOCATION, FIELD_DECL,
    3697              :                            get_identifier ("value"), integer_type_node);
    3698            4 :   DECL_CONTEXT (field) = record_type;
    3699            4 :   TYPE_FIELDS (record_type) = field;
    3700            4 :   layout_type (record_type);
    3701              : 
    3702            4 :   tree call_lhs = build_decl (UNKNOWN_LOCATION, VAR_DECL,
    3703              :                               get_identifier ("readonly_call_mem"),
    3704              :                               record_type);
    3705            4 :   TREE_READONLY (call_lhs) = 1;
    3706            4 :   TREE_STATIC (call_lhs) = 1;
    3707            4 :   TREE_ADDRESSABLE (call_lhs) = 1;
    3708              : 
    3709            4 :   tree fn_type = build_function_type_list (record_type, NULL_TREE);
    3710            4 :   tree fn = build_fn_decl ("nothrow_call", fn_type);
    3711            4 :   gcall *call = gimple_build_call (fn, 0);
    3712            4 :   gimple_call_set_lhs (call, call_lhs);
    3713            4 :   gimple_call_set_nothrow (call, true);
    3714              : 
    3715            4 :   ASSERT_TRUE (gimple_store_p (call));
    3716            4 :   ASSERT_TRUE (gimple_could_trap_p (call));
    3717            4 :   ASSERT_FALSE (gimple_could_trap_p_1 (call, true, false));
    3718              : 
    3719            4 :   gimple_call_set_return_slot_opt (call, true);
    3720            4 :   ASSERT_TRUE (gimple_could_trap_p (call));
    3721            4 :   ASSERT_FALSE (gimple_could_trap_p_1 (call, true, false));
    3722            4 : }
    3723              : 
    3724              : /* Build a GIMPLE_NOP and verify various properties of it.  */
    3725              : 
    3726              : static void
    3727            4 : test_nop_stmt ()
    3728              : {
    3729            4 :   gimple *stmt = gimple_build_nop ();
    3730            4 :   verify_gimple_pp ("GIMPLE_NOP", stmt);
    3731            4 :   ASSERT_EQ (GIMPLE_NOP, gimple_code (stmt));
    3732            4 :   ASSERT_EQ (NULL, gimple_get_lhs (stmt));
    3733            4 :   ASSERT_FALSE (gimple_assign_single_p (stmt));
    3734            4 : }
    3735              : 
    3736              : /* Build a GIMPLE_RETURN equivalent to
    3737              :      return 7;
    3738              :    and verify various properties of it.  */
    3739              : 
    3740              : static void
    3741            4 : test_return_stmt ()
    3742              : {
    3743            4 :   tree type = integer_type_node;
    3744            4 :   tree val = build_int_cst (type, 7);
    3745            4 :   greturn *stmt = gimple_build_return (val);
    3746            4 :   verify_gimple_pp ("return 7;", stmt);
    3747              : 
    3748            4 :   ASSERT_EQ (GIMPLE_RETURN, gimple_code (stmt));
    3749            4 :   ASSERT_EQ (NULL, gimple_get_lhs (stmt));
    3750            4 :   ASSERT_EQ (val, gimple_return_retval (stmt));
    3751            4 :   ASSERT_FALSE (gimple_assign_single_p (stmt));
    3752            4 : }
    3753              : 
    3754              : /* Build a GIMPLE_RETURN equivalent to
    3755              :      return;
    3756              :    and verify various properties of it.  */
    3757              : 
    3758              : static void
    3759            4 : test_return_without_value ()
    3760              : {
    3761            4 :   greturn *stmt = gimple_build_return (NULL);
    3762            4 :   verify_gimple_pp ("return;", stmt);
    3763              : 
    3764            4 :   ASSERT_EQ (GIMPLE_RETURN, gimple_code (stmt));
    3765            4 :   ASSERT_EQ (NULL, gimple_get_lhs (stmt));
    3766            4 :   ASSERT_EQ (NULL, gimple_return_retval (stmt));
    3767            4 :   ASSERT_FALSE (gimple_assign_single_p (stmt));
    3768            4 : }
    3769              : 
    3770              : /* Run all of the selftests within this file.  */
    3771              : 
    3772              : void
    3773            4 : gimple_cc_tests ()
    3774              : {
    3775            4 :   test_assign_single ();
    3776            4 :   test_assign_binop ();
    3777            4 :   test_could_trap ();
    3778            4 :   test_nop_stmt ();
    3779            4 :   test_return_stmt ();
    3780            4 :   test_return_without_value ();
    3781            4 : }
    3782              : 
    3783              : } // namespace selftest
    3784              : 
    3785              : 
    3786              : #endif /* CHECKING_P */
        

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