LCOV - code coverage report
Current view: top level - gcc - tree-ssanames.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 81.6 % 483 394
Test Date: 2026-12-05 16:10:02 Functions: 93.2 % 44 41
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Generic routines for manipulating SSA_NAME expressions
       2              :    Copyright (C) 2003-2026 Free Software Foundation, Inc.
       3              : 
       4              : This file is part of GCC.
       5              : 
       6              : GCC is free software; you can redistribute it and/or modify
       7              : it under the terms of the GNU General Public License as published by
       8              : the Free Software Foundation; either version 3, or (at your option)
       9              : any later version.
      10              : 
      11              : GCC is distributed in the hope that it will be useful,
      12              : but WITHOUT ANY WARRANTY; without even the implied warranty of
      13              : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14              : GNU General Public License for more details.
      15              : 
      16              : You should have received a copy of the GNU General Public License
      17              : along with GCC; see the file COPYING3.  If not see
      18              : <http://www.gnu.org/licenses/>.  */
      19              : 
      20              : #include "config.h"
      21              : #include "system.h"
      22              : #include "coretypes.h"
      23              : #include "backend.h"
      24              : #include "tree.h"
      25              : #include "gimple.h"
      26              : #include "tree-pass.h"
      27              : #include "ssa.h"
      28              : #include "gimple-pretty-print.h"
      29              : #include "gimple-iterator.h"
      30              : #include "stor-layout.h"
      31              : #include "tree-into-ssa.h"
      32              : #include "tree-ssa.h"
      33              : #include "cfgloop.h"
      34              : #include "tree-scalar-evolution.h"
      35              : #include "value-query.h"
      36              : #include "value-range-storage.h"
      37              : 
      38              : /* Rewriting a function into SSA form can create a huge number of SSA_NAMEs,
      39              :    many of which may be thrown away shortly after their creation if jumps
      40              :    were threaded through PHI nodes.
      41              : 
      42              :    While our garbage collection mechanisms will handle this situation, it
      43              :    is extremely wasteful to create nodes and throw them away, especially
      44              :    when the nodes can be reused.
      45              : 
      46              :    For PR 8361, we can significantly reduce the number of nodes allocated
      47              :    and thus the total amount of memory allocated by managing SSA_NAMEs a
      48              :    little.  This additionally helps reduce the amount of work done by the
      49              :    garbage collector.  Similar results have been seen on a wider variety
      50              :    of tests (such as the compiler itself).
      51              : 
      52              :    Right now we maintain our free list on a per-function basis.  It may
      53              :    or may not make sense to maintain the free list for the duration of
      54              :    a compilation unit.
      55              : 
      56              :    External code should rely solely upon HIGHEST_SSA_VERSION and the
      57              :    externally defined functions.  External code should not know about
      58              :    the details of the free list management.
      59              : 
      60              :    External code should also not assume the version number on nodes is
      61              :    monotonically increasing.  We reuse the version number when we
      62              :    reuse an SSA_NAME expression.  This helps keep arrays and bitmaps
      63              :    more compact.  */
      64              : 
      65              : 
      66              : /* Version numbers with special meanings.  We start allocating new version
      67              :    numbers after the special ones.  */
      68              : #define UNUSED_NAME_VERSION 0
      69              : 
      70              : unsigned int ssa_name_nodes_reused;
      71              : unsigned int ssa_name_nodes_created;
      72              : 
      73              : #define FREE_SSANAMES(fun) (fun)->gimple_df->free_ssanames
      74              : #define FREE_SSANAMES_QUEUE(fun) (fun)->gimple_df->free_ssanames_queue
      75              : 
      76              : /* Return TRUE if R fits in the global range of NAME.  */
      77              : 
      78              : inline bool
      79      6858082 : range_info_fits_p (tree name, const vrange &r)
      80              : {
      81      6858082 :   gcc_checking_assert (SSA_NAME_RANGE_INFO (name));
      82      6858082 :   vrange_storage *mem = SSA_NAME_RANGE_INFO (name);
      83      6858082 :   return mem->fits_p (r);
      84              : }
      85              : 
      86              : /* Allocate a new global range for NAME and set it to R.  Return the
      87              :    allocation slot.  */
      88              : 
      89              : inline vrange_storage *
      90     28825055 : range_info_alloc (tree name, const vrange &r)
      91              : {
      92     28825055 :   vrange_storage *mem = ggc_alloc_vrange_storage (r);
      93     28825055 :   SSA_NAME_RANGE_INFO (name) = mem;
      94     28825055 :   return mem;
      95              : }
      96              : 
      97              : /* Free storage allocated for the global range for NAME.  */
      98              : 
      99              : inline void
     100      1243548 : range_info_free (tree name)
     101              : {
     102      1243548 :   vrange_storage *mem = SSA_NAME_RANGE_INFO (name);
     103      1243548 :   ggc_free (mem);
     104      1243548 : }
     105              : 
     106              : /* Attach PT to NAME, creating range storage if necessary.  */
     107              : 
     108              : static void
     109     19058783 : set_pt_solution (tree name, pt_solution *pt)
     110              : {
     111     19058783 :   gcc_checking_assert (POINTER_TYPE_P (TREE_TYPE (name)));
     112     19058783 :   if (!SSA_NAME_RANGE_INFO (name))
     113     11817152 :     SSA_NAME_RANGE_INFO (name) = ggc_alloc_vrange_storage (TREE_TYPE (name));
     114     19058783 :   ssa_name_prange_info (name)->pt = pt;
     115     19058783 : }
     116              : 
     117              : /* Return NAME's solution, creating an unknown solution if necessary.  */
     118              : 
     119              : static pt_solution *
     120     24197772 : get_pt_solution (tree name)
     121              : {
     122     24197772 :   gcc_assert (POINTER_TYPE_P (TREE_TYPE (name)));
     123     24197772 :   prange_storage *s = ssa_name_prange_info (name);
     124     24197772 :   if (s && s->pt)
     125              :     return s->pt;
     126     15185222 :   pt_solution *pt = ggc_cleared_alloc<pt_solution> ();
     127     15185222 :   pt_solution_reset (pt);
     128     15185222 :   set_pt_solution (name, pt);
     129     15185222 :   return pt;
     130              : }
     131              : 
     132              : /* Make PT the points-to solution for NAME.  */
     133              : 
     134              : void
     135     24197772 : set_ssa_name_pt_solution (tree name, const pt_solution &pt)
     136              : {
     137     24197772 :   *get_pt_solution (name) = pt;
     138     24197772 : }
     139              : 
     140              : /* Return the global range for NAME in R.  */
     141              : 
     142              : inline void
     143    330651900 : range_info_get_range (const_tree name, vrange &r)
     144              : {
     145    330651900 :   SSA_NAME_RANGE_INFO (name)->get_vrange (r, TREE_TYPE (name));
     146    330651900 : }
     147              : 
     148              : /* Set the global range for NAME from R.  Return TRUE if successful,
     149              :    or FALSE if we can't set a range of NAME's type.  */
     150              : 
     151              : inline bool
     152     34439589 : range_info_set_range (tree name, const vrange &r)
     153              : {
     154     34439589 :   if (!SSA_NAME_RANGE_INFO (name) || !range_info_fits_p (name, r))
     155              :     {
     156              :       // Preserve SSA-owned points-to information when the
     157              :       // variable-sized range storage must grow.
     158     28825055 :       pt_solution *pt = NULL;
     159     28825055 :       if (prange_storage *old = ssa_name_prange_info (name))
     160       636743 :         pt = old->pt;
     161     28825055 :       if (SSA_NAME_RANGE_INFO (name))
     162      1243548 :         range_info_free (name);
     163              : 
     164     28825055 :       vrange_storage *mem = range_info_alloc (name, r);
     165     28825055 :       if (mem && pt)
     166              :         {
     167       525745 :           prange_storage *s = mem->dyn_prange ();
     168       525745 :           s->pt = pt;
     169              :         }
     170              :       return mem != NULL;
     171              :     }
     172              :   else
     173              :     {
     174      5614534 :       SSA_NAME_RANGE_INFO (name)->set_vrange (r);
     175      5614534 :       return true;
     176              :     }
     177              : }
     178              : 
     179              : /* Initialize management of SSA_NAMEs to default SIZE.  If SIZE is
     180              :    zero use default.  */
     181              : 
     182              : void
     183      3436727 : init_ssanames (struct function *fn, int size)
     184              : {
     185      3436727 :   if (!size)
     186      3349867 :     vec_alloc (SSANAMES (fn), 50);
     187              :   else
     188        86860 :     vec_safe_reserve (SSANAMES (fn), size, true);
     189              : 
     190              :   /* Version 0 is special, so reserve the first slot in the table.  Though
     191              :      currently unused, we may use version 0 in alias analysis as part of
     192              :      the heuristics used to group aliases when the alias sets are too
     193              :      large.
     194              : 
     195              :      We use vec::quick_push here because we know that SSA_NAMES has at
     196              :      least 50 elements reserved in it.  */
     197      3436727 :   SSANAMES (fn)->quick_push (NULL_TREE);
     198      3436727 :   FREE_SSANAMES (fn) = NULL;
     199      3436727 :   FREE_SSANAMES_QUEUE (fn) = NULL;
     200              : 
     201      3436727 :   fn->gimple_df->ssa_renaming_needed = 0;
     202      3436727 :   fn->gimple_df->rename_vops = 0;
     203      3436727 : }
     204              : 
     205              : /* Finalize management of SSA_NAMEs.  */
     206              : 
     207              : void
     208      3324820 : fini_ssanames (struct function *fn)
     209              : {
     210      3324820 :   unsigned i;
     211      3324820 :   tree name;
     212              :   /* Some SSA names leak into global tree data structures so we can't simply
     213              :      ggc_free them.  But make sure to clear references to stmts since we now
     214              :      ggc_free the CFG itself.  */
     215     99544696 :   FOR_EACH_VEC_SAFE_ELT (SSANAMES (fn), i, name)
     216     96219876 :     if (name)
     217     69022508 :       SSA_NAME_DEF_STMT (name) = NULL;
     218      3324820 :   vec_free (SSANAMES (fn));
     219      3324820 :   vec_free (FREE_SSANAMES (fn));
     220      3324820 :   vec_free (FREE_SSANAMES_QUEUE (fn));
     221      3324820 : }
     222              : 
     223              : /* Dump some simple statistics regarding the re-use of SSA_NAME nodes.  */
     224              : 
     225              : void
     226            0 : ssanames_print_statistics (void)
     227              : {
     228            0 :   fprintf (stderr, "%-32s" PRsa (11) "\n", "SSA_NAME nodes allocated:",
     229            0 :            SIZE_AMOUNT (ssa_name_nodes_created));
     230            0 :   fprintf (stderr, "%-32s" PRsa (11) "\n", "SSA_NAME nodes reused:",
     231            0 :            SIZE_AMOUNT (ssa_name_nodes_reused));
     232            0 : }
     233              : 
     234              : /* Verify the state of the SSA_NAME lists.
     235              : 
     236              :    There must be no duplicates on the free list.
     237              :    Every name on the free list must be marked as on the free list.
     238              :    Any name on the free list must not appear in the IL.
     239              :    No names can be leaked.  */
     240              : 
     241              : DEBUG_FUNCTION void
     242            0 : verify_ssaname_freelists (struct function *fun)
     243              : {
     244            0 :   if (!gimple_in_ssa_p (fun))
     245            0 :     return;
     246              : 
     247            0 :   auto_bitmap names_in_il;
     248              : 
     249              :   /* Walk the entire IL noting every SSA_NAME we see.  */
     250            0 :   basic_block bb;
     251            0 :   FOR_EACH_BB_FN (bb, fun)
     252              :     {
     253            0 :       tree t;
     254              :       /* First note the result and arguments of PHI nodes.  */
     255            0 :       for (gphi_iterator gsi = gsi_start_phis (bb);
     256            0 :            !gsi_end_p (gsi);
     257            0 :            gsi_next (&gsi))
     258              :         {
     259            0 :           gphi *phi = gsi.phi ();
     260            0 :           t = gimple_phi_result (phi);
     261            0 :           bitmap_set_bit (names_in_il, SSA_NAME_VERSION (t));
     262              : 
     263            0 :           for (unsigned int i = 0; i < gimple_phi_num_args (phi); i++)
     264              :             {
     265            0 :               t = gimple_phi_arg_def (phi, i);
     266            0 :               if (TREE_CODE (t) == SSA_NAME)
     267            0 :                 bitmap_set_bit (names_in_il, SSA_NAME_VERSION (t));
     268              :             }
     269              :         }
     270              : 
     271              :       /* Then note the operands of each statement.  */
     272            0 :       for (gimple_stmt_iterator gsi = gsi_start_bb (bb);
     273            0 :            !gsi_end_p (gsi);
     274            0 :            gsi_next (&gsi))
     275              :         {
     276            0 :           ssa_op_iter iter;
     277            0 :           gimple *stmt = gsi_stmt (gsi);
     278            0 :           FOR_EACH_SSA_TREE_OPERAND (t, stmt, iter, SSA_OP_ALL_OPERANDS)
     279            0 :             bitmap_set_bit (names_in_il, SSA_NAME_VERSION (t));
     280              :         }
     281              :     }
     282              : 
     283              :   /* Now walk the free list noting what we find there and verifying
     284              :      there are no duplicates.  */
     285            0 :   auto_bitmap names_in_freelists;
     286            0 :   if (FREE_SSANAMES (fun))
     287              :     {
     288            0 :       for (unsigned int i = 0; i < FREE_SSANAMES (fun)->length (); i++)
     289              :         {
     290            0 :           tree t = (*FREE_SSANAMES (fun))[i];
     291              : 
     292              :           /* Verify that the name is marked as being in the free list.  */
     293            0 :           gcc_assert (SSA_NAME_IN_FREE_LIST (t));
     294              : 
     295              :           /* Verify the name has not already appeared in the free list and
     296              :              note it in the list of names found in the free list.  */
     297            0 :           gcc_assert (!bitmap_bit_p (names_in_freelists, SSA_NAME_VERSION (t)));
     298            0 :           bitmap_set_bit (names_in_freelists, SSA_NAME_VERSION (t));
     299              :         }
     300              :     }
     301              : 
     302              :   /* Similarly for the names in the pending free list.  */
     303            0 :   if (FREE_SSANAMES_QUEUE (fun))
     304              :     {
     305            0 :       for (unsigned int i = 0; i < FREE_SSANAMES_QUEUE (fun)->length (); i++)
     306              :         {
     307            0 :           tree t = (*FREE_SSANAMES_QUEUE (fun))[i];
     308              : 
     309              :           /* Verify that the name is marked as being in the free list.  */
     310            0 :           gcc_assert (SSA_NAME_IN_FREE_LIST (t));
     311              : 
     312              :           /* Verify the name has not already appeared in the free list and
     313              :              note it in the list of names found in the free list.  */
     314            0 :           gcc_assert (!bitmap_bit_p (names_in_freelists, SSA_NAME_VERSION (t)));
     315            0 :           bitmap_set_bit (names_in_freelists, SSA_NAME_VERSION (t));
     316              :         }
     317              :     }
     318              : 
     319              :   /* If any name appears in both the IL and the freelists, then
     320              :      something horrible has happened.  */
     321            0 :   bool intersect_p = bitmap_intersect_p (names_in_il, names_in_freelists);
     322            0 :   gcc_assert (!intersect_p);
     323              : 
     324              :   /* Names can be queued up for release if there is an ssa update
     325              :      pending.  Pretend we saw them in the IL.  */
     326            0 :   if (names_to_release)
     327            0 :     bitmap_ior_into (names_in_il, names_to_release);
     328              : 
     329              :   /* Function splitting can "lose" SSA_NAMEs in an effort to ensure that
     330              :      debug/non-debug compilations have the same SSA_NAMEs.  So for each
     331              :      lost SSA_NAME, see if it's likely one from that wart.  These will always
     332              :      be marked as default definitions.  So we loosely assume that anything
     333              :      marked as a default definition isn't leaked by pretending they are
     334              :      in the IL.  */
     335            0 :   for (unsigned int i = UNUSED_NAME_VERSION + 1; i < num_ssa_names; i++)
     336            0 :     if (ssa_name (i) && SSA_NAME_IS_DEFAULT_DEF (ssa_name (i)))
     337            0 :       bitmap_set_bit (names_in_il, i);
     338              : 
     339            0 :   unsigned int i;
     340            0 :   bitmap_iterator bi;
     341            0 :   auto_bitmap all_names;
     342            0 :   bitmap_set_range (all_names, UNUSED_NAME_VERSION + 1, num_ssa_names - 1);
     343            0 :   bitmap_ior_into (names_in_il, names_in_freelists);
     344              : 
     345              :   /* Any name not mentioned in the IL and not in the feelists
     346              :      has been leaked.  */
     347            0 :   EXECUTE_IF_AND_COMPL_IN_BITMAP(all_names, names_in_il,
     348              :                                  UNUSED_NAME_VERSION + 1, i, bi)
     349            0 :     gcc_assert (!ssa_name (i));
     350            0 : }
     351              : 
     352              : /* Move all SSA_NAMEs from FREE_SSA_NAMES_QUEUE to FREE_SSA_NAMES.
     353              : 
     354              :    We do not, but should have a mode to verify the state of the SSA_NAMEs
     355              :    lists.  In particular at this point every name must be in the IL,
     356              :    on the free list or in the queue.  Anything else is an error.  */
     357              : 
     358              : void
     359    652278367 : flush_ssaname_freelist (void)
     360              : {
     361              :   /* If there were any SSA names released reset the SCEV cache.  */
     362    652278367 :   if (! vec_safe_is_empty (FREE_SSANAMES_QUEUE (cfun)))
     363     11061250 :     scev_reset_htab ();
     364    652278367 :   vec_safe_splice (FREE_SSANAMES (cfun), FREE_SSANAMES_QUEUE (cfun));
     365    652278367 :   vec_safe_truncate (FREE_SSANAMES_QUEUE (cfun), 0);
     366    652278367 : }
     367              : 
     368              : /* Initialize SSA_NAME_IMM_USE_NODE of a SSA NAME.  */
     369              : 
     370              : void
     371    158310972 : init_ssa_name_imm_use (tree name)
     372              : {
     373    158310972 :   use_operand_p imm;
     374    158310972 :   imm = &(SSA_NAME_IMM_USE_NODE (name));
     375    158310972 :   imm->use = NULL;
     376    158310972 :   imm->prev = imm;
     377    158310972 :   imm->next = imm;
     378    158310972 :   imm->loc.ssa_name = name;
     379    158310972 : }
     380              : 
     381              : /* Return an SSA_NAME node for variable VAR defined in statement STMT
     382              :    in function FN.  STMT may be an empty statement for artificial
     383              :    references (e.g., default definitions created when a variable is
     384              :    used without a preceding definition).  If VERISON is not zero then
     385              :    allocate the SSA name with that version.  */
     386              : 
     387              : tree
     388    156614596 : make_ssa_name_fn (struct function *fn, tree var, gimple *stmt,
     389              :                   unsigned int version)
     390              : {
     391    156614596 :   tree t;
     392    156614596 :   gcc_assert (VAR_P (var)
     393              :               || TREE_CODE (var) == PARM_DECL
     394              :               || TREE_CODE (var) == RESULT_DECL
     395              :               || (TYPE_P (var) && is_gimple_reg_type (var)));
     396              : 
     397              :   /* Get the specified SSA name version.  */
     398    156614596 :   if (version != 0)
     399              :     {
     400         8572 :       t = make_node (SSA_NAME);
     401         8572 :       SSA_NAME_VERSION (t) = version;
     402         8572 :       if (version >= SSANAMES (fn)->length ())
     403         2343 :         vec_safe_grow_cleared (SSANAMES (fn), version + 1, true);
     404         8572 :       gcc_assert ((*SSANAMES (fn))[version] == NULL);
     405         8572 :       (*SSANAMES (fn))[version] = t;
     406         8572 :       ssa_name_nodes_created++;
     407              :     }
     408              :   /* If our free list has an element, then use it.  */
     409    156606024 :   else if (!vec_safe_is_empty (FREE_SSANAMES (fn)))
     410              :     {
     411     32625624 :       t = FREE_SSANAMES (fn)->pop ();
     412     32625624 :       ssa_name_nodes_reused++;
     413              : 
     414              :       /* The node was cleared out when we put it on the free list, so
     415              :          there is no need to do so again here.  */
     416     32625624 :       gcc_assert ((*SSANAMES (fn))[SSA_NAME_VERSION (t)] == NULL);
     417     32625624 :       (*SSANAMES (fn))[SSA_NAME_VERSION (t)] = t;
     418              :     }
     419              :   else
     420              :     {
     421    123980400 :       t = make_node (SSA_NAME);
     422    123980400 :       SSA_NAME_VERSION (t) = SSANAMES (fn)->length ();
     423    123980400 :       vec_safe_push (SSANAMES (fn), t);
     424    123980400 :       ssa_name_nodes_created++;
     425              :     }
     426              : 
     427    156614596 :   if (TYPE_P (var))
     428              :     {
     429     59961688 :       TREE_TYPE (t) = TYPE_MAIN_VARIANT (var);
     430     59961688 :       SET_SSA_NAME_VAR_OR_IDENTIFIER (t, NULL_TREE);
     431              :     }
     432              :   else
     433              :     {
     434     96652908 :       TREE_TYPE (t) = TREE_TYPE (var);
     435    141960276 :       SET_SSA_NAME_VAR_OR_IDENTIFIER (t, var);
     436              :     }
     437    156614596 :   SSA_NAME_DEF_STMT (t) = stmt;
     438    156614596 :   SSA_NAME_RANGE_INFO (t) = NULL;
     439              : 
     440    156614596 :   SSA_NAME_IN_FREE_LIST (t) = 0;
     441    156614596 :   SSA_NAME_IS_DEFAULT_DEF (t) = 0;
     442    156614596 :   init_ssa_name_imm_use (t);
     443              : #if defined ENABLE_GIMPLE_CHECKING
     444    156614596 :   t->ssa_name.active_iterated_stmt = NULL;
     445    156614596 :   t->ssa_name.fast_iteration_depth = 0;
     446              : #endif
     447              : 
     448    156614596 :   return t;
     449              : }
     450              : 
     451              : /* Update the range information for NAME, intersecting into an existing
     452              :    range if applicable.  Return TRUE if the range was updated.  */
     453              : 
     454              : bool
     455     49729544 : set_range_info (tree name, const vrange &r)
     456              : {
     457     49729544 :   if (r.undefined_p () || r.varying_p ())
     458              :     return false;
     459              : 
     460              :   // Pick up the current range, or VARYING if none.
     461     49538875 :   tree type = TREE_TYPE (name);
     462     49538875 :   value_range tmp (type);
     463     49538875 :   if (SSA_NAME_RANGE_INFO (name))
     464     40011331 :     range_info_get_range (name, tmp);
     465              :   else
     466      9527544 :     tmp.set_varying (type);
     467              : 
     468              :   // If the result doesn't change, or is undefined, return false.
     469     49538875 :   if (!tmp.intersect (r) || tmp.undefined_p ())
     470              :     return false;
     471              : 
     472     16096454 :   if (!range_info_set_range (name, tmp))
     473              :     return false;
     474              : 
     475     16096454 :   if (dump_file)
     476              :     {
     477         5173 :       value_range tmp (type);
     478         5173 :       fprintf (dump_file, "Global Exported: ");
     479         5173 :       print_generic_expr (dump_file, name, TDF_SLIM);
     480         5173 :       fprintf (dump_file, " = ");
     481         5173 :       gimple_range_global (tmp, name);
     482         5173 :       tmp.dump (dump_file);
     483         5173 :       fputc ('\n', dump_file);
     484         5173 :     }
     485              :   // Update the active query, if needed.
     486     16096454 :   get_range_query (cfun)->update_range_info (name, r);
     487     16096454 :   return true;
     488     49538875 : }
     489              : 
     490              : /* query nonnull attribute for pointer NAME.  */
     491              : 
     492              : bool
     493     37673969 : ptr_nonnull_p (tree name)
     494              : {
     495     37673969 :   gcc_assert (POINTER_TYPE_P (TREE_TYPE (name)));
     496     37673969 :   prange_storage *ps = ssa_name_prange_info (name);
     497     37673969 :   return ps ? ps->nonnull_p (TREE_TYPE (name)) : false;
     498              : }
     499              : 
     500              : /* Set nonnull attribute to pointer NAME.  */
     501              : 
     502              : void
     503      4702136 : set_ptr_nonnull (tree name)
     504              : {
     505      4702136 :   gcc_assert (POINTER_TYPE_P (TREE_TYPE (name)));
     506      4702136 :   prange_storage *ps = ssa_name_prange_info (name);
     507      4702136 :   if (ps)
     508              :     {
     509      4702136 :       ps->set_nonnull (TREE_TYPE (name));
     510      4702136 :       return;
     511              :     }
     512            0 :   prange pr;
     513            0 :   pr.set_nonzero (TREE_TYPE (name));
     514            0 :   range_info_set_range (name, pr);
     515            0 : }
     516              : 
     517              : /* Update the non-zero bits bitmask of NAME.  */
     518              : 
     519              : void
     520            1 : set_nonzero_bits (tree name, const wide_int &mask)
     521              : {
     522            1 :   if (POINTER_TYPE_P (TREE_TYPE (name)))
     523              :     {
     524            0 :       prange p (TREE_TYPE (name));
     525            0 :       p.set_nonzero_bits (mask);
     526            0 :       set_range_info (name, p);
     527            0 :       return;
     528            0 :     }
     529              : 
     530            1 :   int_range<2> r (TREE_TYPE (name));
     531            1 :   r.set_nonzero_bits (mask);
     532            1 :   set_range_info (name, r);
     533            1 : }
     534              : 
     535              : /* Update the known bits of NAME.
     536              : 
     537              :    Zero bits in MASK cover constant values.  Set bits in MASK cover
     538              :    unknown values.  VALUE are the known bits.  */
     539              : 
     540              : void
     541     15512225 : set_bitmask (tree name, const wide_int &value, const wide_int &mask)
     542              : {
     543     15512225 :   if (POINTER_TYPE_P (TREE_TYPE (name)))
     544              :     {
     545      1462002 :       prange p (TREE_TYPE (name));
     546      1462002 :       p.update_bitmask (irange_bitmask (value, mask));
     547      1462002 :       set_range_info (name, p);
     548      1462002 :       return;
     549      1462002 :     }
     550              : 
     551     14050223 :   int_range_max r (TREE_TYPE (name));
     552     14050223 :   r.update_bitmask (irange_bitmask (value, mask));
     553     14050223 :   set_range_info (name, r);
     554     14050223 : }
     555              : 
     556              : /* Return a wide_int with potentially non-zero bits in SSA_NAME
     557              :    NAME, the constant for INTEGER_CST, or -1 if unknown.  */
     558              : 
     559              : static wide_int
     560    938438872 : get_nonzero_bits_1 (const_tree name)
     561              : {
     562    938438872 :   if (TREE_CODE (name) == INTEGER_CST)
     563    172476252 :     return wi::to_wide (name);
     564              : 
     565    765962620 :   if (POLY_INT_CST_P (name))
     566              :     return -known_alignment (wi::to_poly_wide (name));
     567              : 
     568              :   /* Use element_precision instead of TYPE_PRECISION so complex and
     569              :      vector types get a non-zero precision.  */
     570    765962620 :   unsigned int precision = element_precision (TREE_TYPE (name));
     571              : 
     572    765962620 :   if (VECTOR_TYPE_P (TREE_TYPE (name)))
     573              :     {
     574        41294 :       tree elem = uniform_vector_p (name);
     575        41294 :       if (elem)
     576         2012 :         return get_nonzero_bits_1 (elem);
     577              :     }
     578              : 
     579    765960608 :   if (TREE_CODE (name) != SSA_NAME || !SSA_NAME_RANGE_INFO (name))
     580    495379484 :     return wi::shwi (-1, precision);
     581              : 
     582              :   // Alignment information is encoded in the bitmask, so pointers simply
     583              :   // need to extract the bitmask like integers do.
     584    270581124 :   if (POINTER_TYPE_P (TREE_TYPE (name)))
     585              :     {
     586     46372760 :       prange_storage *s = ssa_name_prange_info (name);
     587     46372760 :       gcc_checking_assert (s);
     588     46372760 :       return s->get_bitmask (TREE_TYPE (name)).get_nonzero_bits ();
     589              :     }
     590              : 
     591    224208364 :   if (!irange::supports_p (TREE_TYPE (name)))
     592       713018 :     return wi::shwi (-1, precision);
     593              : 
     594    223495346 :   int_range_max tmp;
     595    223495346 :   range_info_get_range (name, tmp);
     596    223495346 :   return tmp.get_nonzero_bits ();
     597    223495346 : }
     598              : 
     599              : /* Return a wide_int with potentially non-zero bits in SSA_NAME
     600              :    NAME, the constant for INTEGER_CST, or -1 if unknown.
     601              :    In addition to what get_nonzero_bits_1 handles, this handles one
     602              :    level of BIT_AND_EXPR, either as a def_stmt or tree directly.  */
     603              : 
     604              : wide_int
     605    881419069 : get_nonzero_bits (const_tree name)
     606              : {
     607    881419069 :   if (TREE_CODE (name) == BIT_AND_EXPR)
     608      3694830 :     return (get_nonzero_bits_1 (TREE_OPERAND (name, 0))
     609      5542245 :             & get_nonzero_bits_1 (TREE_OPERAND (name, 1)));
     610    879571654 :   if (TREE_CODE (name) == SSA_NAME)
     611              :     {
     612    723960237 :       auto *g = safe_dyn_cast<gassign *> (SSA_NAME_DEF_STMT (name));
     613    531755785 :       if (g
     614    531755785 :           && gimple_assign_rhs_code (g) == BIT_AND_EXPR)
     615     82755564 :         return (get_nonzero_bits_1 (name)
     616    110340752 :                 & get_nonzero_bits_1 (gimple_assign_rhs1 (g))
     617     82755564 :                 & get_nonzero_bits_1 (gimple_assign_rhs2 (g)));
     618              :     }
     619    851986466 :   return get_nonzero_bits_1 (name);
     620              : }
     621              : 
     622              : /* Return a wide_int with known non-zero bits in SSA_NAME
     623              :    NAME (bits whose values aren't known are also clear), the constant
     624              :    for INTEGER_CST, or 0 if unknown.  */
     625              : 
     626              : static wide_int
     627    399012366 : get_known_nonzero_bits_1 (const_tree name)
     628              : {
     629    399012366 :   if (TREE_CODE (name) == INTEGER_CST)
     630    185787006 :     return wi::to_wide (name);
     631              : 
     632              :   /* Use element_precision instead of TYPE_PRECISION so complex and
     633              :      vector types get a non-zero precision.  */
     634    213225360 :   unsigned int precision = element_precision (TREE_TYPE (name));
     635    213225360 :   if (TREE_CODE (name) != SSA_NAME)
     636        15164 :     return wi::shwi (0, precision);
     637              : 
     638    213210196 :   if (!SSA_NAME_RANGE_INFO (name))
     639    164356223 :     return wi::shwi (0, precision);
     640              : 
     641              :   // Known pointer bits, including alignment, are encoded in the bitmask
     642     48853973 :   if (POINTER_TYPE_P (TREE_TYPE (name)))
     643              :     {
     644            0 :       prange_storage *s = ssa_name_prange_info (name);
     645            0 :       gcc_checking_assert (s);
     646            0 :       if (s->undefined_p ())
     647            0 :         return wi::shwi (0, precision);
     648            0 :       irange_bitmask bm = s->get_bitmask (TREE_TYPE (name));
     649            0 :       return wi::bit_and_not (bm.value (), bm.mask ());
     650            0 :     }
     651              : 
     652     48853973 :   if (!irange::supports_p (TREE_TYPE (name)))
     653            0 :     return wi::shwi (0, precision);
     654              : 
     655     48853973 :   int_range_max tmp;
     656     48853973 :   range_info_get_range (name, tmp);
     657     48853973 :   if (tmp.undefined_p ())
     658            0 :     return wi::shwi (0, precision);
     659     48853973 :   irange_bitmask bm = tmp.get_bitmask ();
     660     48854011 :   return wi::bit_and_not (bm.value (), bm.mask ());
     661     48853973 : }
     662              : 
     663              : /* Return a wide_int with known non-zero bits in SSA_NAME
     664              :    NAME, the constant for INTEGER_CST, or 0 if unknown.
     665              :    In addition to what get_known_nonzero_bits_1 handles, this handles one
     666              :    level of BIT_IOR_EXPR, either as a def_stmt or tree directly.  */
     667              : 
     668              : wide_int
     669    390732704 : get_known_nonzero_bits (const_tree name)
     670              : {
     671    390732704 :   if (TREE_CODE (name) == BIT_IOR_EXPR)
     672       543988 :     return (get_known_nonzero_bits_1 (TREE_OPERAND (name, 0))
     673       815982 :             | get_known_nonzero_bits_1 (TREE_OPERAND (name, 1)));
     674    390460710 :   if (TREE_CODE (name) == SSA_NAME)
     675              :     {
     676    204701639 :       auto *g = safe_dyn_cast<gassign *> (SSA_NAME_DEF_STMT (name));
     677    137113348 :       if (g
     678    137113348 :           && gimple_assign_rhs_code (g) == BIT_IOR_EXPR)
     679     12011502 :         return (get_known_nonzero_bits_1 (name)
     680     16015336 :                 | get_known_nonzero_bits_1 (gimple_assign_rhs1 (g))
     681     12011502 :                 | get_known_nonzero_bits_1 (gimple_assign_rhs2 (g)));
     682              :     }
     683    386456876 :   return get_known_nonzero_bits_1 (name);
     684              : }
     685              : 
     686              : /* Return TRUE is OP, an SSA_NAME has a range of values [0..1] at the
     687              :    STMT, false otherwise.
     688              : 
     689              :    This can be because it is a boolean type, any unsigned integral
     690              :    type with a single bit of precision, or has known range of [0..1]
     691              :    via range analysis.  */
     692              : 
     693              : bool
     694     20258450 : ssa_name_has_boolean_range (tree op, gimple *stmt)
     695              : {
     696     20258450 :   gcc_assert (TREE_CODE (op) == SSA_NAME);
     697              : 
     698              :   /* An integral type with a single bit of precision.  */
     699     40154001 :   if (INTEGRAL_TYPE_P (TREE_TYPE (op))
     700     15633179 :       && TYPE_UNSIGNED (TREE_TYPE (op))
     701     29415231 :       && TYPE_PRECISION (TREE_TYPE (op)) == 1)
     702              :     return true;
     703              : 
     704              :   /* An integral type with more precision, but the object
     705              :      only takes on values [0..1] as determined by range
     706              :      analysis.  */
     707     34581594 :   if (INTEGRAL_TYPE_P (TREE_TYPE (op))
     708     29956323 :       && (TYPE_PRECISION (TREE_TYPE (op)) > 1))
     709              :     {
     710     12845472 :       int_range<2> r;
     711     25690944 :       if (get_range_query (cfun)->range_of_expr (r, op, stmt)
     712     12845472 :           && r == range_true_and_false (TREE_TYPE (op)))
     713              :         return true;
     714              : 
     715     12471873 :       if (wi::eq_p (get_nonzero_bits (op), 1))
     716              :         return true;
     717     12845472 :     }
     718              : 
     719              :   return false;
     720              : }
     721              : 
     722              : /* We no longer need the SSA_NAME expression VAR, release it so that
     723              :    it may be reused.
     724              : 
     725              :    Note it is assumed that no calls to make_ssa_name will be made
     726              :    until all uses of the ssa name are released and that the only
     727              :    use of the SSA_NAME expression is to check its SSA_NAME_VAR.  All
     728              :    other fields must be assumed clobbered.  */
     729              : 
     730              : void
     731     87705067 : release_ssa_name_fn (struct function *fn, tree var)
     732              : {
     733     87705067 :   if (!var)
     734              :     return;
     735              : 
     736              :   /* Never release the default definition for a symbol.  It's a
     737              :      special SSA name that should always exist once it's created.  */
     738     87705067 :   if (SSA_NAME_IS_DEFAULT_DEF (var))
     739              :     return;
     740              : 
     741              :   /* If VAR has been registered for SSA updating, don't remove it.
     742              :      After update_ssa has run, the name will be released.  */
     743     87705039 :   if (name_registered_for_update_p (var))
     744              :     {
     745       849610 :       release_ssa_name_after_update_ssa (var);
     746       849610 :       return;
     747              :     }
     748              : 
     749              :   /* release_ssa_name can be called multiple times on a single SSA_NAME.
     750              :      However, it should only end up on our free list one time.   We
     751              :      keep a status bit in the SSA_NAME node itself to indicate it has
     752              :      been put on the free list.
     753              : 
     754              :      Note that once on the freelist you cannot reference the SSA_NAME's
     755              :      defining statement.  */
     756     86855429 :   if (! SSA_NAME_IN_FREE_LIST (var))
     757              :     {
     758     86855429 :       int saved_ssa_name_version = SSA_NAME_VERSION (var);
     759     86855429 :       use_operand_p imm = &(SSA_NAME_IMM_USE_NODE (var));
     760              : 
     761     86855429 :       if (MAY_HAVE_DEBUG_BIND_STMTS)
     762     56692876 :         insert_debug_temp_for_var_def (NULL, var);
     763              : 
     764     86855429 :       if (flag_checking)
     765     86854848 :         verify_imm_links (stderr, var);
     766     98004508 :       while (imm->next != imm)
     767     11149079 :         delink_imm_use (imm->next);
     768              : 
     769     86855429 :       (*SSANAMES (fn))[SSA_NAME_VERSION (var)] = NULL_TREE;
     770     86855429 :       memset (var, 0, tree_size (var));
     771              : 
     772     86855429 :       imm->prev = imm;
     773     86855429 :       imm->next = imm;
     774     86855429 :       imm->loc.ssa_name = var;
     775              : 
     776              :       /* First put back the right tree node so that the tree checking
     777              :          macros do not complain.  */
     778     86855429 :       TREE_SET_CODE (var, SSA_NAME);
     779              : 
     780              :       /* Restore the version number.  */
     781     86855429 :       SSA_NAME_VERSION (var) = saved_ssa_name_version;
     782              : 
     783              :       /* Note this SSA_NAME is now in the first list.  */
     784     86855429 :       SSA_NAME_IN_FREE_LIST (var) = 1;
     785              : 
     786              :       /* Put in a non-NULL TREE_TYPE so dumping code will not ICE
     787              :          if it happens to come along a released SSA name and tries
     788              :          to inspect its type.  */
     789     86855429 :       TREE_TYPE (var) = error_mark_node;
     790              : 
     791              :       /* And finally queue it so that it will be put on the free list.  */
     792     86855429 :       vec_safe_push (FREE_SSANAMES_QUEUE (fn), var);
     793              :     }
     794              : }
     795              : 
     796              : /* Return the bitmask expressing byte alignment ALIGN with byte offset
     797              :    MISALIGN for a pointer of type TYPE.  */
     798              : 
     799              : static irange_bitmask
     800       367386 : alignment_to_bitmask (tree type, unsigned int align, unsigned int misalign)
     801              : {
     802              :   /* ptr & (ALIGN - 1) == MISALIGN says the low log2(ALIGN) bits of the pointer
     803              :      are known and hold MISALIGN, so the unknown-bit mask is ~(ALIGN - 1) and
     804              :      the known value is MISALIGN.
     805              :      An ALIGN of 1 carries no information and yields an unknown bitmask.  */
     806       367386 :   unsigned int prec = TYPE_PRECISION (type);
     807       367386 :   wide_int value = wi::uhwi (misalign, prec);
     808       367386 :   wide_int low_bits = wi::uhwi (align - 1, prec);
     809       367386 :   return irange_bitmask (value, ~low_bits);
     810       367386 : }
     811              : 
     812              : /* if BM contains usable alignment info, return the byte alignment and offset
     813              :    in ALIGNP and MISALIGNP.  Otherwise return FALSE.  */
     814              : 
     815              : static bool
     816     48081782 : bitmask_to_alignment (const irange_bitmask &bm, unsigned int *alignp,
     817              :                       unsigned int *misalignp)
     818              : {
     819     48081782 :   if (bm.unknown_p ())
     820              :     return false;
     821              : 
     822      5387521 :   wide_int mask = bm.mask ();
     823      5387521 :   unsigned int bit;
     824              : 
     825              :   /* A fully known pointer supports any representable alignment, with
     826              :      the corresponding offset.  Otherwise stop at the first unknown bit.  */
     827     10775042 :   bit = mask == 0 ? bm.value ().get_precision () : wi::ctz (mask);
     828      5387521 :   if (bit == 0)
     829              :     return false;
     830              : 
     831              :   /* A more strongly calculated alignment should simply be max alignment.  */
     832      5293277 :   if (bit > HOST_BITS_PER_INT - 1)
     833              :     bit = HOST_BITS_PER_INT - 1;
     834              : 
     835      5293277 :   *alignp = 1u << bit;
     836      5293277 :   *misalignp = wi::extract_uhwi (bm.value (), 0, bit);
     837      5293277 :   return true;
     838      5387521 : }
     839              : 
     840              : /* Extract useful alignment information from NAME's global range.  Return
     841              :    false if no alignment beyond byte alignment is known.  */
     842              : 
     843              : bool
     844     54863698 : get_ssa_name_alignment (const_tree name, unsigned int *alignp,
     845              :                         unsigned int *misalignp)
     846              : {
     847    109717118 :   if (!POINTER_TYPE_P (TREE_TYPE (name)) || !SSA_NAME_RANGE_INFO (name))
     848              :     return false;
     849              : 
     850     48081782 :   prange_storage *s = ssa_name_prange_info (name);
     851     48081782 :   if (!s)
     852              :     return false;
     853              : 
     854     48081782 :   return bitmask_to_alignment (s->get_bitmask (TREE_TYPE (name)),
     855              :                                alignp, misalignp);
     856              : }
     857              : 
     858              : /* Clear NAME's known bits independently of the legacy alignment fields.  */
     859              : 
     860              : void
     861            0 : mark_ssa_name_alignment_unknown (tree name)
     862              : {
     863            0 :   if (!SSA_NAME_RANGE_INFO (name))
     864            0 :     return;
     865              : 
     866            0 :   prange r (TREE_TYPE (name));
     867            0 :   range_info_get_range (name, r);
     868            0 :   if (r.undefined_p ())
     869            0 :     return;
     870              : 
     871              :   /* Withdraw the known bits or the alignment survives in the bitmask.  */
     872            0 :   irange_bitmask unknown (TYPE_PRECISION (TREE_TYPE (name)));
     873            0 :   r.update_bitmask (unknown);
     874            0 :   range_info_set_range (name, r);
     875            0 : }
     876              : 
     877              : /* Refine NAME's bitmask with ALIGN and MISALIGN.  Preserve the existing
     878              :    information if the requested alignment conflicts with known bits.  */
     879              : 
     880              : void
     881       367386 : set_ssa_name_alignment (tree name, unsigned int align, unsigned int misalign)
     882              : {
     883       367386 :   gcc_checking_assert (align != 0);
     884       367386 :   gcc_assert ((align & (align - 1)) == 0);
     885       367386 :   gcc_assert ((misalign & ~(align - 1)) == 0);
     886       367386 :   gcc_assert (POINTER_TYPE_P (TREE_TYPE (name)));
     887              : 
     888       367386 :   tree type = TREE_TYPE (name);
     889       367386 :   irange_bitmask bm = alignment_to_bitmask (type, align, misalign);
     890       367386 :   if (bm.unknown_p ())
     891              :     return;
     892              : 
     893       341057 :   prange r (type);
     894       341057 :   if (SSA_NAME_RANGE_INFO (name))
     895       289172 :     range_info_get_range (name, r);
     896       341057 :   if (r.undefined_p ())
     897              :     return;
     898              : 
     899       341057 :   irange_bitmask cur = r.get_bitmask ();
     900       341057 :   if (!cur.intersect (bm))
     901            0 :     return;
     902              : 
     903       341057 :   r.update_bitmask (cur);
     904       341057 :   if (!r.undefined_p ())
     905       341057 :     range_info_set_range (name, r);
     906       367386 : }
     907              : 
     908              : 
     909              : /* Creates a new SSA name using the template NAME tobe defined by
     910              :    statement STMT in function FN.  */
     911              : 
     912              : tree
     913     20329769 : copy_ssa_name_fn (struct function *fn, tree name, gimple *stmt)
     914              : {
     915     20329769 :   tree new_name;
     916              : 
     917     20329769 :   if (SSA_NAME_VAR (name))
     918     12910489 :     new_name = make_ssa_name_fn (fn, SSA_NAME_VAR (name), stmt);
     919              :   else
     920              :     {
     921      7419280 :       new_name = make_ssa_name_fn (fn, TREE_TYPE (name), stmt);
     922     14838560 :       SET_SSA_NAME_VAR_OR_IDENTIFIER (new_name, SSA_NAME_IDENTIFIER (name));
     923              :     }
     924              : 
     925     20329769 :   return new_name;
     926              : }
     927              : 
     928              : /* Give DEST its own copy of the points-to information of
     929              :    the SSA name SRC.  SRC may be NULL_TREE or carry no information, in
     930              :    which case DEST is left alone.  */
     931              : 
     932              : void
     933      3152405 : duplicate_ssa_name_pt_solution (tree dest, const pt_solution* pt)
     934              : {
     935      3152405 :   gcc_assert (POINTER_TYPE_P (TREE_TYPE (dest)));
     936      5594921 :   gcc_assert (!ssa_name_pt_solution (dest));
     937              : 
     938      3152405 :   if (!pt)
     939              :     return;
     940      3109630 :   pt_solution *copy = ggc_alloc<pt_solution> ();
     941      3109630 :   *copy = *pt;
     942      3109630 :   set_pt_solution (dest, copy);
     943              : }
     944              : 
     945              : /* Give DEST its own copy of the points-to information of
     946              :    the SSA name SRC.  SRC may be NULL_TREE or carry no information, in
     947              :    which case DEST is left alone.  */
     948              : 
     949              : void
     950      7590643 : duplicate_ssa_name_pt_solution (tree dest, tree src)
     951              : {
     952      7590643 :   if (!src)
     953              :      return;
     954              : 
     955     10507390 :   if (const pt_solution *pt = ssa_name_pt_solution (src))
     956      2733585 :     duplicate_ssa_name_pt_solution (dest, pt);
     957              : }
     958              : 
     959              : /* Copy any global range information from SRC to NAME.  If REMOVE_LOCAL_ADDR
     960              :    is true, then any specified address that a prange may refer to is checked
     961              :    to see if it's local to the function and removed if so.
     962              :    The default is FALSE, which is the previous default behaviour and copies
     963              :    the entire range as is.  */
     964              : 
     965              : void
     966     18002078 : duplicate_ssa_name_range_info (tree name, tree src, bool remove_local_addr)
     967              : {
     968     18002078 :   gcc_checking_assert (!SSA_NAME_RANGE_INFO (name));
     969              : 
     970     18002078 :   if (!SSA_NAME_RANGE_INFO (src))
     971            0 :     return;
     972              : 
     973     18002078 :   value_range src_range (TREE_TYPE (src));
     974     18002078 :   range_info_get_range (src, src_range);
     975              : 
     976              :   /* Remove any local addresses from the range if present.  */
     977     18002078 :   if (remove_local_addr && is_a <prange> (src_range))
     978      6483555 :     as_a <prange> (src_range).clear_function_local_addr ();
     979     18002078 :   range_info_set_range (name, src_range);
     980     18002078 : }
     981              : 
     982              : /* For a SSA copy DEST = SRC duplicate SSA info present on DEST to SRC
     983              :    to preserve it in case DEST is eliminated to SRC.  */
     984              : 
     985              : void
     986     55764230 : maybe_duplicate_ssa_info_at_copy (tree dest, tree src)
     987              : {
     988              :   /* While points-to info is flow-insensitive we have to avoid copying
     989              :      info from not executed regions invoking UB to dominating defs.  */
     990     55764230 :   if (gimple_bb (SSA_NAME_DEF_STMT (src))
     991     55764230 :       != gimple_bb (SSA_NAME_DEF_STMT (dest)))
     992              :     return;
     993              : 
     994     43214241 :   if (SSA_NAME_RANGE_INFO (dest) && !SSA_NAME_RANGE_INFO (src))
     995              :     {
     996       622977 :       duplicate_ssa_name_range_info (src, dest);
     997       622977 :       duplicate_ssa_name_pt_solution (src, dest);
     998              :     }
     999              : }
    1000              : 
    1001              : 
    1002              : /* Creates a duplicate of a ssa name NAME tobe defined by statement STMT
    1003              :    in function FN.  */
    1004              : 
    1005              : tree
    1006     18599922 : duplicate_ssa_name_fn (struct function *fn, tree name, gimple *stmt)
    1007              : {
    1008     18599922 :   tree new_name = copy_ssa_name_fn (fn, name, stmt);
    1009              : 
    1010     18599922 :   if (SSA_NAME_RANGE_INFO (name))
    1011              :     {
    1012      6676542 :       duplicate_ssa_name_range_info (new_name, name);
    1013      6676542 :       duplicate_ssa_name_pt_solution (new_name, name);
    1014              :     }
    1015              : 
    1016     18599922 :   return new_name;
    1017              : }
    1018              : 
    1019              : 
    1020              : /* Reset all flow sensitive data on NAME such as range-info, nonzero
    1021              :    bits and alignment.  */
    1022              : 
    1023              : void
    1024      7978193 : reset_flow_sensitive_info (tree name)
    1025              : {
    1026              :   /* Aliasing info is not flow sensitive, so preserve it if present.  */
    1027      7978193 :   prange_storage *s = ssa_name_prange_info (name);
    1028      7978193 :   pt_solution *pt = s ? s->pt : NULL;
    1029              : 
    1030      7978193 :   SSA_NAME_RANGE_INFO (name) = NULL;
    1031      7978193 :   if (pt)
    1032       763931 :     set_pt_solution (name, pt);
    1033              : 
    1034              :   // Clear range info in the current range query.
    1035     15956386 :   get_range_query (cfun)->reset_range_info (name);
    1036      7978193 : }
    1037              : 
    1038              : /* Clear all flow sensitive data from all statements and PHI definitions
    1039              :    in BB.  */
    1040              : 
    1041              : void
    1042      1422194 : reset_flow_sensitive_info_in_bb (basic_block bb)
    1043              : {
    1044      4147603 :   for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
    1045      1303215 :        gsi_next (&gsi))
    1046              :     {
    1047      1303215 :       gimple *stmt = gsi_stmt (gsi);
    1048      1303215 :       ssa_op_iter i;
    1049      1303215 :       tree op;
    1050      1569330 :       FOR_EACH_SSA_TREE_OPERAND (op, stmt, i, SSA_OP_DEF)
    1051       266115 :         reset_flow_sensitive_info (op);
    1052              :     }
    1053              : 
    1054      1434988 :   for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
    1055        12794 :        gsi_next (&gsi))
    1056              :     {
    1057        12794 :       tree phi_def = gimple_phi_result (gsi.phi ());
    1058        12794 :       reset_flow_sensitive_info (phi_def);
    1059              :     }
    1060      1422194 : }
    1061              : 
    1062              : /* Release all the SSA_NAMEs created by STMT.  */
    1063              : 
    1064              : void
    1065     79077570 : release_defs (gimple *stmt)
    1066              : {
    1067     79077570 :   tree def;
    1068     79077570 :   ssa_op_iter iter;
    1069              : 
    1070    133122509 :   FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_ALL_DEFS)
    1071     54044939 :     if (TREE_CODE (def) == SSA_NAME)
    1072     53492130 :       release_ssa_name (def);
    1073     79077570 : }
    1074              : 
    1075              : 
    1076              : /* Replace the symbol associated with SSA_NAME with SYM.  */
    1077              : 
    1078              : void
    1079        13004 : replace_ssa_name_symbol (tree ssa_name, tree sym)
    1080              : {
    1081        13004 :   SET_SSA_NAME_VAR_OR_IDENTIFIER (ssa_name, sym);
    1082        13004 :   TREE_TYPE (ssa_name) = TREE_TYPE (sym);
    1083        13004 : }
    1084              : 
    1085              : /* Release the vector of free SSA_NAMEs and compact the vector of SSA_NAMEs
    1086              :    that are live.  */
    1087              : 
    1088              : static void
    1089      2997776 : release_free_names_and_compact_live_names (function *fun)
    1090              : {
    1091      2997776 :   unsigned i, j;
    1092      2997776 :   int n = vec_safe_length (FREE_SSANAMES (fun));
    1093              : 
    1094              :   /* Now release the freelist.  */
    1095      2997776 :   vec_free (FREE_SSANAMES (fun));
    1096              : 
    1097              :   /* And compact the SSA number space.  We make sure to not change the
    1098              :      relative order of SSA versions.  */
    1099     86460427 :   for (i = 1, j = 1; i < fun->gimple_df->ssa_names->length (); ++i)
    1100              :     {
    1101     83462651 :       tree name = ssa_name (i);
    1102     83462651 :       if (name)
    1103              :         {
    1104     52895251 :           if (i != j)
    1105              :             {
    1106     33009498 :               SSA_NAME_VERSION (name) = j;
    1107     33009498 :               (*fun->gimple_df->ssa_names)[j] = name;
    1108              :             }
    1109     52895251 :           j++;
    1110              :         }
    1111              :     }
    1112      2997776 :   fun->gimple_df->ssa_names->truncate (j);
    1113              : 
    1114      2997776 :   statistics_counter_event (fun, "SSA names released", n);
    1115      2997776 :   statistics_counter_event (fun, "SSA name holes removed", i - j);
    1116      2997776 :   if (dump_file)
    1117          350 :     fprintf (dump_file, "Released %i names, %.2f%%, removed %i holes\n",
    1118          350 :              n, n * 100.0 / num_ssa_names, i - j);
    1119      2997776 : }
    1120              : 
    1121              : /* Return SSA names that are unused to GGC memory and compact the SSA
    1122              :    version namespace.  This is used to keep footprint of compiler during
    1123              :    interprocedural optimization.  */
    1124              : 
    1125              : namespace {
    1126              : 
    1127              : const pass_data pass_data_release_ssa_names =
    1128              : {
    1129              :   GIMPLE_PASS, /* type */
    1130              :   "release_ssa", /* name */
    1131              :   OPTGROUP_NONE, /* optinfo_flags */
    1132              :   TV_TREE_SSA_OTHER, /* tv_id */
    1133              :   PROP_ssa, /* properties_required */
    1134              :   0, /* properties_provided */
    1135              :   0, /* properties_destroyed */
    1136              :   TODO_remove_unused_locals, /* todo_flags_start */
    1137              :   0, /* todo_flags_finish */
    1138              : };
    1139              : 
    1140              : class pass_release_ssa_names : public gimple_opt_pass
    1141              : {
    1142              : public:
    1143       302985 :   pass_release_ssa_names (gcc::context *ctxt)
    1144       605970 :     : gimple_opt_pass (pass_data_release_ssa_names, ctxt)
    1145              :   {}
    1146              : 
    1147              :   /* opt_pass methods: */
    1148              :   unsigned int execute (function *) final override;
    1149              : 
    1150              : }; // class pass_release_ssa_names
    1151              : 
    1152              : unsigned int
    1153      2997776 : pass_release_ssa_names::execute (function *fun)
    1154              : {
    1155      2997776 :   release_free_names_and_compact_live_names (fun);
    1156      2997776 :   return 0;
    1157              : }
    1158              : 
    1159              : } // anon namespace
    1160              : 
    1161              : gimple_opt_pass *
    1162       302985 : make_pass_release_ssa_names (gcc::context *ctxt)
    1163              : {
    1164       302985 :   return new pass_release_ssa_names (ctxt);
    1165              : }
        

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.