LCOV - code coverage report
Current view: top level - gcc - tree-ssanames.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 83.8 % 452 379
Test Date: 2024-12-21 13:15:12 Functions: 88.6 % 44 39
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Generic routines for manipulating SSA_NAME expressions
       2                 :             :    Copyright (C) 2003-2024 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 NAME has global range info.  */
      77                 :             : 
      78                 :             : inline bool
      79                 :   909864626 : range_info_p (const_tree name)
      80                 :             : {
      81                 :   909864626 :   return SSA_NAME_RANGE_INFO (name);
      82                 :             : }
      83                 :             : 
      84                 :             : /* Return TRUE if R fits in the global range of NAME.  */
      85                 :             : 
      86                 :             : inline bool
      87                 :     2916204 : range_info_fits_p (tree name, const vrange &r)
      88                 :             : {
      89                 :     2916204 :   gcc_checking_assert (range_info_p (name));
      90                 :     2916204 :   vrange_storage *mem = SSA_NAME_RANGE_INFO (name);
      91                 :     2916204 :   return mem->fits_p (r);
      92                 :             : }
      93                 :             : 
      94                 :             : /* Allocate a new global range for NAME and set it to R.  Return the
      95                 :             :    allocation slot.  */
      96                 :             : 
      97                 :             : inline void *
      98                 :    15086008 : range_info_alloc (tree name, const vrange &r)
      99                 :             : {
     100                 :    15086008 :   vrange_storage *mem = ggc_alloc_vrange_storage (r);
     101                 :    15086008 :   SSA_NAME_RANGE_INFO (name) = mem;
     102                 :    15086008 :   return mem;
     103                 :             : }
     104                 :             : 
     105                 :             : /* Free storage allocated for the global range for NAME.  */
     106                 :             : 
     107                 :             : inline void
     108                 :      635939 : range_info_free (tree name)
     109                 :             : {
     110                 :      635939 :   vrange_storage *mem = SSA_NAME_RANGE_INFO (name);
     111                 :      635939 :   ggc_free (mem);
     112                 :      635939 : }
     113                 :             : 
     114                 :             : /* Return the global range for NAME in R.  */
     115                 :             : 
     116                 :             : inline void
     117                 :   270228319 : range_info_get_range (const_tree name, vrange &r)
     118                 :             : {
     119                 :   270228319 :   SSA_NAME_RANGE_INFO (name)->get_vrange (r, TREE_TYPE (name));
     120                 :   270228319 : }
     121                 :             : 
     122                 :             : /* Set the global range for NAME from R.  Return TRUE if successfull,
     123                 :             :    or FALSE if we can't set a range of NAME's type.  */
     124                 :             : 
     125                 :             : inline bool
     126                 :    17366273 : range_info_set_range (tree name, const vrange &r)
     127                 :             : {
     128                 :    17366273 :   if (!range_info_p (name) || !range_info_fits_p (name, r))
     129                 :             :     {
     130                 :    15086008 :       if (range_info_p (name))
     131                 :      635939 :         range_info_free (name);
     132                 :             : 
     133                 :    15086008 :       return range_info_alloc (name, r);
     134                 :             :     }
     135                 :             :   else
     136                 :             :     {
     137                 :     2280265 :       SSA_NAME_RANGE_INFO (name)->set_vrange (r);
     138                 :     2280265 :       return true;
     139                 :             :     }
     140                 :             : }
     141                 :             : 
     142                 :             : /* Initialize management of SSA_NAMEs to default SIZE.  If SIZE is
     143                 :             :    zero use default.  */
     144                 :             : 
     145                 :             : void
     146                 :     3032726 : init_ssanames (struct function *fn, int size)
     147                 :             : {
     148                 :     3032726 :   if (!size)
     149                 :     2949580 :     vec_alloc (SSANAMES (fn), 50);
     150                 :             :   else
     151                 :       83146 :     vec_safe_reserve (SSANAMES (fn), size, true);
     152                 :             : 
     153                 :             :   /* Version 0 is special, so reserve the first slot in the table.  Though
     154                 :             :      currently unused, we may use version 0 in alias analysis as part of
     155                 :             :      the heuristics used to group aliases when the alias sets are too
     156                 :             :      large.
     157                 :             : 
     158                 :             :      We use vec::quick_push here because we know that SSA_NAMES has at
     159                 :             :      least 50 elements reserved in it.  */
     160                 :     3032726 :   SSANAMES (fn)->quick_push (NULL_TREE);
     161                 :     3032726 :   FREE_SSANAMES (fn) = NULL;
     162                 :     3032726 :   FREE_SSANAMES_QUEUE (fn) = NULL;
     163                 :             : 
     164                 :     3032726 :   fn->gimple_df->ssa_renaming_needed = 0;
     165                 :     3032726 :   fn->gimple_df->rename_vops = 0;
     166                 :     3032726 : }
     167                 :             : 
     168                 :             : /* Finalize management of SSA_NAMEs.  */
     169                 :             : 
     170                 :             : void
     171                 :     2928225 : fini_ssanames (struct function *fn)
     172                 :             : {
     173                 :     2928225 :   unsigned i;
     174                 :     2928225 :   tree name;
     175                 :             :   /* Some SSA names leak into global tree data structures so we can't simply
     176                 :             :      ggc_free them.  But make sure to clear references to stmts since we now
     177                 :             :      ggc_free the CFG itself.  */
     178                 :    86958122 :   FOR_EACH_VEC_SAFE_ELT (SSANAMES (fn), i, name)
     179                 :    84029897 :     if (name)
     180                 :    61097043 :       SSA_NAME_DEF_STMT (name) = NULL;
     181                 :     2928225 :   vec_free (SSANAMES (fn));
     182                 :     2928225 :   vec_free (FREE_SSANAMES (fn));
     183                 :     2928225 :   vec_free (FREE_SSANAMES_QUEUE (fn));
     184                 :     2928225 : }
     185                 :             : 
     186                 :             : /* Dump some simple statistics regarding the re-use of SSA_NAME nodes.  */
     187                 :             : 
     188                 :             : void
     189                 :           0 : ssanames_print_statistics (void)
     190                 :             : {
     191                 :           0 :   fprintf (stderr, "%-32s" PRsa (11) "\n", "SSA_NAME nodes allocated:",
     192                 :           0 :            SIZE_AMOUNT (ssa_name_nodes_created));
     193                 :           0 :   fprintf (stderr, "%-32s" PRsa (11) "\n", "SSA_NAME nodes reused:",
     194                 :           0 :            SIZE_AMOUNT (ssa_name_nodes_reused));
     195                 :           0 : }
     196                 :             : 
     197                 :             : /* Verify the state of the SSA_NAME lists.
     198                 :             : 
     199                 :             :    There must be no duplicates on the free list.
     200                 :             :    Every name on the free list must be marked as on the free list.
     201                 :             :    Any name on the free list must not appear in the IL.
     202                 :             :    No names can be leaked.  */
     203                 :             : 
     204                 :             : DEBUG_FUNCTION void
     205                 :           0 : verify_ssaname_freelists (struct function *fun)
     206                 :             : {
     207                 :           0 :   if (!gimple_in_ssa_p (fun))
     208                 :           0 :     return;
     209                 :             : 
     210                 :           0 :   auto_bitmap names_in_il;
     211                 :             : 
     212                 :             :   /* Walk the entire IL noting every SSA_NAME we see.  */
     213                 :           0 :   basic_block bb;
     214                 :           0 :   FOR_EACH_BB_FN (bb, fun)
     215                 :             :     {
     216                 :           0 :       tree t;
     217                 :             :       /* First note the result and arguments of PHI nodes.  */
     218                 :           0 :       for (gphi_iterator gsi = gsi_start_phis (bb);
     219                 :           0 :            !gsi_end_p (gsi);
     220                 :           0 :            gsi_next (&gsi))
     221                 :             :         {
     222                 :           0 :           gphi *phi = gsi.phi ();
     223                 :           0 :           t = gimple_phi_result (phi);
     224                 :           0 :           bitmap_set_bit (names_in_il, SSA_NAME_VERSION (t));
     225                 :             : 
     226                 :           0 :           for (unsigned int i = 0; i < gimple_phi_num_args (phi); i++)
     227                 :             :             {
     228                 :           0 :               t = gimple_phi_arg_def (phi, i);
     229                 :           0 :               if (TREE_CODE (t) == SSA_NAME)
     230                 :           0 :                 bitmap_set_bit (names_in_il, SSA_NAME_VERSION (t));
     231                 :             :             }
     232                 :             :         }
     233                 :             : 
     234                 :             :       /* Then note the operands of each statement.  */
     235                 :           0 :       for (gimple_stmt_iterator gsi = gsi_start_bb (bb);
     236                 :           0 :            !gsi_end_p (gsi);
     237                 :           0 :            gsi_next (&gsi))
     238                 :             :         {
     239                 :           0 :           ssa_op_iter iter;
     240                 :           0 :           gimple *stmt = gsi_stmt (gsi);
     241                 :           0 :           FOR_EACH_SSA_TREE_OPERAND (t, stmt, iter, SSA_OP_ALL_OPERANDS)
     242                 :           0 :             bitmap_set_bit (names_in_il, SSA_NAME_VERSION (t));
     243                 :             :         }
     244                 :             :     }
     245                 :             : 
     246                 :             :   /* Now walk the free list noting what we find there and verifying
     247                 :             :      there are no duplicates.  */
     248                 :           0 :   auto_bitmap names_in_freelists;
     249                 :           0 :   if (FREE_SSANAMES (fun))
     250                 :             :     {
     251                 :           0 :       for (unsigned int i = 0; i < FREE_SSANAMES (fun)->length (); i++)
     252                 :             :         {
     253                 :           0 :           tree t = (*FREE_SSANAMES (fun))[i];
     254                 :             : 
     255                 :             :           /* Verify that the name is marked as being in the free list.  */
     256                 :           0 :           gcc_assert (SSA_NAME_IN_FREE_LIST (t));
     257                 :             : 
     258                 :             :           /* Verify the name has not already appeared in the free list and
     259                 :             :              note it in the list of names found in the free list.  */
     260                 :           0 :           gcc_assert (!bitmap_bit_p (names_in_freelists, SSA_NAME_VERSION (t)));
     261                 :           0 :           bitmap_set_bit (names_in_freelists, SSA_NAME_VERSION (t));
     262                 :             :         }
     263                 :             :     }
     264                 :             : 
     265                 :             :   /* Similarly for the names in the pending free list.  */
     266                 :           0 :   if (FREE_SSANAMES_QUEUE (fun))
     267                 :             :     {
     268                 :           0 :       for (unsigned int i = 0; i < FREE_SSANAMES_QUEUE (fun)->length (); i++)
     269                 :             :         {
     270                 :           0 :           tree t = (*FREE_SSANAMES_QUEUE (fun))[i];
     271                 :             : 
     272                 :             :           /* Verify that the name is marked as being in the free list.  */
     273                 :           0 :           gcc_assert (SSA_NAME_IN_FREE_LIST (t));
     274                 :             : 
     275                 :             :           /* Verify the name has not already appeared in the free list and
     276                 :             :              note it in the list of names found in the free list.  */
     277                 :           0 :           gcc_assert (!bitmap_bit_p (names_in_freelists, SSA_NAME_VERSION (t)));
     278                 :           0 :           bitmap_set_bit (names_in_freelists, SSA_NAME_VERSION (t));
     279                 :             :         }
     280                 :             :     }
     281                 :             : 
     282                 :             :   /* If any name appears in both the IL and the freelists, then
     283                 :             :      something horrible has happened.  */
     284                 :           0 :   bool intersect_p = bitmap_intersect_p (names_in_il, names_in_freelists);
     285                 :           0 :   gcc_assert (!intersect_p);
     286                 :             : 
     287                 :             :   /* Names can be queued up for release if there is an ssa update
     288                 :             :      pending.  Pretend we saw them in the IL.  */
     289                 :           0 :   if (names_to_release)
     290                 :           0 :     bitmap_ior_into (names_in_il, names_to_release);
     291                 :             : 
     292                 :             :   /* Function splitting can "lose" SSA_NAMEs in an effort to ensure that
     293                 :             :      debug/non-debug compilations have the same SSA_NAMEs.  So for each
     294                 :             :      lost SSA_NAME, see if it's likely one from that wart.  These will always
     295                 :             :      be marked as default definitions.  So we loosely assume that anything
     296                 :             :      marked as a default definition isn't leaked by pretending they are
     297                 :             :      in the IL.  */
     298                 :           0 :   for (unsigned int i = UNUSED_NAME_VERSION + 1; i < num_ssa_names; i++)
     299                 :           0 :     if (ssa_name (i) && SSA_NAME_IS_DEFAULT_DEF (ssa_name (i)))
     300                 :           0 :       bitmap_set_bit (names_in_il, i);
     301                 :             : 
     302                 :           0 :   unsigned int i;
     303                 :           0 :   bitmap_iterator bi;
     304                 :           0 :   auto_bitmap all_names;
     305                 :           0 :   bitmap_set_range (all_names, UNUSED_NAME_VERSION + 1, num_ssa_names - 1);
     306                 :           0 :   bitmap_ior_into (names_in_il, names_in_freelists);
     307                 :             : 
     308                 :             :   /* Any name not mentioned in the IL and not in the feelists
     309                 :             :      has been leaked.  */
     310                 :           0 :   EXECUTE_IF_AND_COMPL_IN_BITMAP(all_names, names_in_il,
     311                 :             :                                  UNUSED_NAME_VERSION + 1, i, bi)
     312                 :           0 :     gcc_assert (!ssa_name (i));
     313                 :           0 : }
     314                 :             : 
     315                 :             : /* Move all SSA_NAMEs from FREE_SSA_NAMES_QUEUE to FREE_SSA_NAMES.
     316                 :             : 
     317                 :             :    We do not, but should have a mode to verify the state of the SSA_NAMEs
     318                 :             :    lists.  In particular at this point every name must be in the IL,
     319                 :             :    on the free list or in the queue.  Anything else is an error.  */
     320                 :             : 
     321                 :             : void
     322                 :   590596521 : flush_ssaname_freelist (void)
     323                 :             : {
     324                 :             :   /* If there were any SSA names released reset the SCEV cache.  */
     325                 :   590596521 :   if (! vec_safe_is_empty (FREE_SSANAMES_QUEUE (cfun)))
     326                 :     9727690 :     scev_reset_htab ();
     327                 :   590596521 :   vec_safe_splice (FREE_SSANAMES (cfun), FREE_SSANAMES_QUEUE (cfun));
     328                 :   590596521 :   vec_safe_truncate (FREE_SSANAMES_QUEUE (cfun), 0);
     329                 :   590596521 : }
     330                 :             : 
     331                 :             : /* Initialize SSA_NAME_IMM_USE_NODE of a SSA NAME.  */
     332                 :             : 
     333                 :             : void
     334                 :   137967301 : init_ssa_name_imm_use (tree name)
     335                 :             : {
     336                 :   137967301 :   use_operand_p imm;
     337                 :   137967301 :   imm = &(SSA_NAME_IMM_USE_NODE (name));
     338                 :   137967301 :   imm->use = NULL;
     339                 :   137967301 :   imm->prev = imm;
     340                 :   137967301 :   imm->next = imm;
     341                 :   137967301 :   imm->loc.ssa_name = name;
     342                 :   137967301 : }
     343                 :             : 
     344                 :             : /* Return an SSA_NAME node for variable VAR defined in statement STMT
     345                 :             :    in function FN.  STMT may be an empty statement for artificial
     346                 :             :    references (e.g., default definitions created when a variable is
     347                 :             :    used without a preceding definition).  If VERISON is not zero then
     348                 :             :    allocate the SSA name with that version.  */
     349                 :             : 
     350                 :             : tree
     351                 :   136149701 : make_ssa_name_fn (struct function *fn, tree var, gimple *stmt,
     352                 :             :                   unsigned int version)
     353                 :             : {
     354                 :   136149701 :   tree t;
     355                 :   136149701 :   gcc_assert (VAR_P (var)
     356                 :             :               || TREE_CODE (var) == PARM_DECL
     357                 :             :               || TREE_CODE (var) == RESULT_DECL
     358                 :             :               || (TYPE_P (var) && is_gimple_reg_type (var)));
     359                 :             : 
     360                 :             :   /* Get the specified SSA name version.  */
     361                 :   136149701 :   if (version != 0)
     362                 :             :     {
     363                 :        4383 :       t = make_node (SSA_NAME);
     364                 :        4383 :       SSA_NAME_VERSION (t) = version;
     365                 :        4383 :       if (version >= SSANAMES (fn)->length ())
     366                 :         688 :         vec_safe_grow_cleared (SSANAMES (fn), version + 1, true);
     367                 :        4383 :       gcc_assert ((*SSANAMES (fn))[version] == NULL);
     368                 :        4383 :       (*SSANAMES (fn))[version] = t;
     369                 :        4383 :       ssa_name_nodes_created++;
     370                 :             :     }
     371                 :             :   /* If our free list has an element, then use it.  */
     372                 :   136145318 :   else if (!vec_safe_is_empty (FREE_SSANAMES (fn)))
     373                 :             :     {
     374                 :    27591392 :       t = FREE_SSANAMES (fn)->pop ();
     375                 :    27591392 :       ssa_name_nodes_reused++;
     376                 :             : 
     377                 :             :       /* The node was cleared out when we put it on the free list, so
     378                 :             :          there is no need to do so again here.  */
     379                 :    27591392 :       gcc_assert ((*SSANAMES (fn))[SSA_NAME_VERSION (t)] == NULL);
     380                 :    27591392 :       (*SSANAMES (fn))[SSA_NAME_VERSION (t)] = t;
     381                 :             :     }
     382                 :             :   else
     383                 :             :     {
     384                 :   108553926 :       t = make_node (SSA_NAME);
     385                 :   108553926 :       SSA_NAME_VERSION (t) = SSANAMES (fn)->length ();
     386                 :   108553926 :       vec_safe_push (SSANAMES (fn), t);
     387                 :   108553926 :       ssa_name_nodes_created++;
     388                 :             :     }
     389                 :             : 
     390                 :   136149701 :   if (TYPE_P (var))
     391                 :             :     {
     392                 :    50999665 :       TREE_TYPE (t) = TYPE_MAIN_VARIANT (var);
     393                 :    50999665 :       SET_SSA_NAME_VAR_OR_IDENTIFIER (t, NULL_TREE);
     394                 :             :     }
     395                 :             :   else
     396                 :             :     {
     397                 :    85150036 :       TREE_TYPE (t) = TREE_TYPE (var);
     398                 :   125933636 :       SET_SSA_NAME_VAR_OR_IDENTIFIER (t, var);
     399                 :             :     }
     400                 :   136149701 :   SSA_NAME_DEF_STMT (t) = stmt;
     401                 :   136149701 :   if (POINTER_TYPE_P (TREE_TYPE (t)))
     402                 :    27551919 :     SSA_NAME_PTR_INFO (t) = NULL;
     403                 :             :   else
     404                 :   108597782 :     SSA_NAME_RANGE_INFO (t) = NULL;
     405                 :             : 
     406                 :   136149701 :   SSA_NAME_IN_FREE_LIST (t) = 0;
     407                 :   136149701 :   SSA_NAME_IS_DEFAULT_DEF (t) = 0;
     408                 :   136149701 :   init_ssa_name_imm_use (t);
     409                 :             : 
     410                 :   136149701 :   return t;
     411                 :             : }
     412                 :             : 
     413                 :             : /* Update the range information for NAME, intersecting into an existing
     414                 :             :    range if applicable.  Return TRUE if the range was updated.  */
     415                 :             : 
     416                 :             : bool
     417                 :    40355945 : set_range_info (tree name, const vrange &r)
     418                 :             : {
     419                 :    40355945 :   if (r.undefined_p () || r.varying_p ())
     420                 :             :     return false;
     421                 :             : 
     422                 :             :   // Pick up the current range, or VARYING if none.
     423                 :    40217524 :   tree type = TREE_TYPE (name);
     424                 :    40217524 :   if (POINTER_TYPE_P (type))
     425                 :             :     {
     426                 :     5771122 :       struct ptr_info_def *pi = get_ptr_info (name);
     427                 :             :       // If R is nonnull and pi is not, set nonnull.
     428                 :     5771122 :       if (r.nonzero_p () && (!pi || pi->pt.null))
     429                 :     2185665 :         set_ptr_nonnull (name);
     430                 :             :       else
     431                 :             :         return false;
     432                 :             :     }
     433                 :             :   else
     434                 :             :     {
     435                 :    34446402 :       value_range tmp (type);
     436                 :    34446402 :       if (range_info_p (name))
     437                 :    26913734 :         range_info_get_range (name, tmp);
     438                 :             :       else
     439                 :     7532668 :         tmp.set_varying (type);
     440                 :             :       // If the result doesn't change, or is undefined, return false.
     441                 :    34446402 :       if (!tmp.intersect (r) || tmp.undefined_p ())
     442                 :             :         return false;
     443                 :    10448872 :       if (!range_info_set_range (name, tmp))
     444                 :             :         return false;
     445                 :    34446402 :     }
     446                 :    12634537 :   if (dump_file)
     447                 :             :     {
     448                 :        3901 :       value_range tmp (type);
     449                 :        3901 :       fprintf (dump_file, "Global Exported: ");
     450                 :        3901 :       print_generic_expr (dump_file, name, TDF_SLIM);
     451                 :        3901 :       fprintf (dump_file, " = ");
     452                 :        3901 :       gimple_range_global (tmp, name);
     453                 :        3901 :       tmp.dump (dump_file);
     454                 :        3901 :       fputc ('\n', dump_file);
     455                 :        3901 :     }
     456                 :             :   return true;
     457                 :             : }
     458                 :             : 
     459                 :             : /* Set nonnull attribute to pointer NAME.  */
     460                 :             : 
     461                 :             : void
     462                 :     5386125 : set_ptr_nonnull (tree name)
     463                 :             : {
     464                 :     5386125 :   gcc_assert (POINTER_TYPE_P (TREE_TYPE (name)));
     465                 :     5386125 :   struct ptr_info_def *pi = get_ptr_info (name);
     466                 :     5386125 :   pi->pt.null = 0;
     467                 :     5386125 : }
     468                 :             : 
     469                 :             : /* Update the non-zero bits bitmask of NAME.  */
     470                 :             : 
     471                 :             : void
     472                 :           0 : set_nonzero_bits (tree name, const wide_int &mask)
     473                 :             : {
     474                 :           0 :   gcc_assert (!POINTER_TYPE_P (TREE_TYPE (name)));
     475                 :             : 
     476                 :           0 :   int_range<2> r (TREE_TYPE (name));
     477                 :           0 :   r.set_nonzero_bits (mask);
     478                 :           0 :   set_range_info (name, r);
     479                 :           0 : }
     480                 :             : 
     481                 :             : /* Update the known bits of NAME.
     482                 :             : 
     483                 :             :    Zero bits in MASK cover constant values.  Set bits in MASK cover
     484                 :             :    unknown values.  VALUE are the known bits.  */
     485                 :             : 
     486                 :             : void
     487                 :    12450913 : set_bitmask (tree name, const wide_int &value, const wide_int &mask)
     488                 :             : {
     489                 :    12450913 :   gcc_assert (!POINTER_TYPE_P (TREE_TYPE (name)));
     490                 :             : 
     491                 :    12450913 :   int_range<2> r (TREE_TYPE (name));
     492                 :    12450913 :   r.update_bitmask (irange_bitmask (value, mask));
     493                 :    12450913 :   set_range_info (name, r);
     494                 :    12450913 : }
     495                 :             : 
     496                 :             : /* Return a wide_int with potentially non-zero bits in SSA_NAME
     497                 :             :    NAME, the constant for INTEGER_CST, or -1 if unknown.  */
     498                 :             : 
     499                 :             : static wide_int
     500                 :   837498928 : get_nonzero_bits_1 (const_tree name)
     501                 :             : {
     502                 :   837498928 :   if (TREE_CODE (name) == INTEGER_CST)
     503                 :   155116316 :     return wi::to_wide (name);
     504                 :             : 
     505                 :   682382612 :   if (POLY_INT_CST_P (name))
     506                 :             :     return -known_alignment (wi::to_poly_wide (name));
     507                 :             : 
     508                 :             :   /* Use element_precision instead of TYPE_PRECISION so complex and
     509                 :             :      vector types get a non-zero precision.  */
     510                 :   682382612 :   unsigned int precision = element_precision (TREE_TYPE (name));
     511                 :   682382612 :   if (TREE_CODE (name) != SSA_NAME)
     512                 :      851699 :     return wi::shwi (-1, precision);
     513                 :             : 
     514                 :   681530913 :   if (POINTER_TYPE_P (TREE_TYPE (name)))
     515                 :             :     {
     516                 :    56765424 :       struct ptr_info_def *pi = SSA_NAME_PTR_INFO (name);
     517                 :    56765424 :       if (pi && pi->align)
     518                 :     3021177 :         return wi::shwi (-(HOST_WIDE_INT) pi->align
     519                 :     6042354 :                          | (HOST_WIDE_INT) pi->misalign, precision);
     520                 :    53744247 :       return wi::shwi (-1, precision);
     521                 :             :     }
     522                 :             : 
     523                 :   624765489 :   if (!range_info_p (name) || !irange::supports_p (TREE_TYPE (name)))
     524                 :   429747663 :     return wi::shwi (-1, precision);
     525                 :             : 
     526                 :   195017826 :   int_range_max tmp;
     527                 :   195017826 :   range_info_get_range (name, tmp);
     528                 :   195017826 :   return tmp.get_nonzero_bits ();
     529                 :   195017826 : }
     530                 :             : 
     531                 :             : /* Return a wide_int with potentially non-zero bits in SSA_NAME
     532                 :             :    NAME, the constant for INTEGER_CST, or -1 if unknown.
     533                 :             :    In addition to what get_nonzero_bits_1 handles, this handles one
     534                 :             :    level of BIT_AND_EXPR, either as a def_stmt or tree directly.  */
     535                 :             : 
     536                 :             : wide_int
     537                 :   784361175 : get_nonzero_bits (const_tree name)
     538                 :             : {
     539                 :   784361175 :   if (TREE_CODE (name) == BIT_AND_EXPR)
     540                 :     3174978 :     return (get_nonzero_bits_1 (TREE_OPERAND (name, 0))
     541                 :     4762467 :             & get_nonzero_bits_1 (TREE_OPERAND (name, 1)));
     542                 :   782773686 :   if (TREE_CODE (name) == SSA_NAME)
     543                 :             :     {
     544                 :   644006676 :       gimple *g = SSA_NAME_DEF_STMT (name);
     545                 :   644006676 :       if (g
     546                 :   644006581 :           && is_gimple_assign (g)
     547                 :  1111095977 :           && gimple_assign_rhs_code (g) == BIT_AND_EXPR)
     548                 :    51550264 :         return (get_nonzero_bits_1 (name)
     549                 :   103100528 :                 & get_nonzero_bits_1 (gimple_assign_rhs1 (g))
     550                 :    77325396 :                 & get_nonzero_bits_1 (gimple_assign_rhs2 (g)));
     551                 :             :     }
     552                 :   756998554 :   return get_nonzero_bits_1 (name);
     553                 :             : }
     554                 :             : 
     555                 :             : /* Return a wide_int with known non-zero bits in SSA_NAME
     556                 :             :    NAME (bits whose values aren't known are also clear), the constant
     557                 :             :    for INTEGER_CST, or 0 if unknown.  */
     558                 :             : 
     559                 :             : static wide_int
     560                 :   353478622 : get_known_nonzero_bits_1 (const_tree name)
     561                 :             : {
     562                 :   353478622 :   if (TREE_CODE (name) == INTEGER_CST)
     563                 :   165549567 :     return wi::to_wide (name);
     564                 :             : 
     565                 :             :   /* Use element_precision instead of TYPE_PRECISION so complex and
     566                 :             :      vector types get a non-zero precision.  */
     567                 :   187929055 :   unsigned int precision = element_precision (TREE_TYPE (name));
     568                 :   187929055 :   if (TREE_CODE (name) != SSA_NAME || POINTER_TYPE_P (TREE_TYPE (name)))
     569                 :       14198 :     return wi::shwi (0, precision);
     570                 :             : 
     571                 :   187914857 :   if (!range_info_p (name) || !irange::supports_p (TREE_TYPE (name)))
     572                 :   146535499 :     return wi::shwi (0, precision);
     573                 :             : 
     574                 :    41379358 :   int_range_max tmp;
     575                 :    41379358 :   range_info_get_range (name, tmp);
     576                 :    41379358 :   if (tmp.undefined_p ())
     577                 :           0 :     return wi::shwi (0, precision);
     578                 :    41379358 :   irange_bitmask bm = tmp.get_bitmask ();
     579                 :    41379438 :   return bm.value () & ~bm.mask ();
     580                 :    41379358 : }
     581                 :             : 
     582                 :             : /* Return a wide_int with known non-zero bits in SSA_NAME
     583                 :             :    NAME, the constant for INTEGER_CST, or -1 if unknown.
     584                 :             :    In addition to what get_known_nonzero_bits_1 handles, this handles one
     585                 :             :    level of BIT_IOR_EXPR, either as a def_stmt or tree directly.  */
     586                 :             : 
     587                 :             : wide_int
     588                 :   345550690 : get_known_nonzero_bits (const_tree name)
     589                 :             : {
     590                 :   345550690 :   if (TREE_CODE (name) == BIT_IOR_EXPR)
     591                 :      459656 :     return (get_known_nonzero_bits_1 (TREE_OPERAND (name, 0))
     592                 :      689484 :             | get_known_nonzero_bits_1 (TREE_OPERAND (name, 1)));
     593                 :   345320862 :   if (TREE_CODE (name) == SSA_NAME)
     594                 :             :     {
     595                 :   179800284 :       gimple *g = SSA_NAME_DEF_STMT (name);
     596                 :   179800284 :       if (g
     597                 :   179800284 :           && is_gimple_assign (g)
     598                 :   298838154 :           && gimple_assign_rhs_code (g) == BIT_IOR_EXPR)
     599                 :     7698104 :         return (get_known_nonzero_bits_1 (name)
     600                 :    15396208 :                 | get_known_nonzero_bits_1 (gimple_assign_rhs1 (g))
     601                 :    11547156 :                 | get_known_nonzero_bits_1 (gimple_assign_rhs2 (g)));
     602                 :             :     }
     603                 :   341471810 :   return get_known_nonzero_bits_1 (name);
     604                 :             : }
     605                 :             : 
     606                 :             : /* Return TRUE is OP, an SSA_NAME has a range of values [0..1], false
     607                 :             :    otherwise.
     608                 :             : 
     609                 :             :    This can be because it is a boolean type, any unsigned integral
     610                 :             :    type with a single bit of precision, or has known range of [0..1]
     611                 :             :    via range analysis.  */
     612                 :             : 
     613                 :             : bool
     614                 :    25093568 : ssa_name_has_boolean_range (tree op)
     615                 :             : {
     616                 :    25093568 :   gcc_assert (TREE_CODE (op) == SSA_NAME);
     617                 :             : 
     618                 :             :   /* An integral type with a single bit of precision.  */
     619                 :    49669836 :   if (INTEGRAL_TYPE_P (TREE_TYPE (op))
     620                 :    19769163 :       && TYPE_UNSIGNED (TREE_TYPE (op))
     621                 :    36258414 :       && TYPE_PRECISION (TREE_TYPE (op)) == 1)
     622                 :             :     return true;
     623                 :             : 
     624                 :             :   /* An integral type with more precision, but the object
     625                 :             :      only takes on values [0..1] as determined by range
     626                 :             :      analysis.  */
     627                 :    42830412 :   if (INTEGRAL_TYPE_P (TREE_TYPE (op))
     628                 :    37506007 :       && (TYPE_PRECISION (TREE_TYPE (op)) > 1))
     629                 :             :     {
     630                 :    16348464 :       int_range<2> r;
     631                 :    32696928 :       if (get_range_query (cfun)->range_of_expr (r, op)
     632                 :    16348464 :           && r == range_true_and_false (TREE_TYPE (op)))
     633                 :             :         return true;
     634                 :             : 
     635                 :    15859982 :       if (wi::eq_p (get_nonzero_bits (op), 1))
     636                 :             :         return true;
     637                 :    16348464 :     }
     638                 :             : 
     639                 :             :   return false;
     640                 :             : }
     641                 :             : 
     642                 :             : /* We no longer need the SSA_NAME expression VAR, release it so that
     643                 :             :    it may be reused.
     644                 :             : 
     645                 :             :    Note it is assumed that no calls to make_ssa_name will be made
     646                 :             :    until all uses of the ssa name are released and that the only
     647                 :             :    use of the SSA_NAME expression is to check its SSA_NAME_VAR.  All
     648                 :             :    other fields must be assumed clobbered.  */
     649                 :             : 
     650                 :             : void
     651                 :    75070298 : release_ssa_name_fn (struct function *fn, tree var)
     652                 :             : {
     653                 :    75070298 :   if (!var)
     654                 :             :     return;
     655                 :             : 
     656                 :             :   /* Never release the default definition for a symbol.  It's a
     657                 :             :      special SSA name that should always exist once it's created.  */
     658                 :    75070298 :   if (SSA_NAME_IS_DEFAULT_DEF (var))
     659                 :             :     return;
     660                 :             : 
     661                 :             :   /* If VAR has been registered for SSA updating, don't remove it.
     662                 :             :      After update_ssa has run, the name will be released.  */
     663                 :    75070298 :   if (name_registered_for_update_p (var))
     664                 :             :     {
     665                 :      704505 :       release_ssa_name_after_update_ssa (var);
     666                 :      704505 :       return;
     667                 :             :     }
     668                 :             : 
     669                 :             :   /* release_ssa_name can be called multiple times on a single SSA_NAME.
     670                 :             :      However, it should only end up on our free list one time.   We
     671                 :             :      keep a status bit in the SSA_NAME node itself to indicate it has
     672                 :             :      been put on the free list.
     673                 :             : 
     674                 :             :      Note that once on the freelist you cannot reference the SSA_NAME's
     675                 :             :      defining statement.  */
     676                 :    74365793 :   if (! SSA_NAME_IN_FREE_LIST (var))
     677                 :             :     {
     678                 :    74365793 :       int saved_ssa_name_version = SSA_NAME_VERSION (var);
     679                 :    74365793 :       use_operand_p imm = &(SSA_NAME_IMM_USE_NODE (var));
     680                 :             : 
     681                 :    74365793 :       if (MAY_HAVE_DEBUG_BIND_STMTS)
     682                 :    48803209 :         insert_debug_temp_for_var_def (NULL, var);
     683                 :             : 
     684                 :    74365793 :       if (flag_checking)
     685                 :    74365215 :         verify_imm_links (stderr, var);
     686                 :    83226872 :       while (imm->next != imm)
     687                 :    83226872 :         delink_imm_use (imm->next);
     688                 :             : 
     689                 :    74365793 :       (*SSANAMES (fn))[SSA_NAME_VERSION (var)] = NULL_TREE;
     690                 :    74365793 :       memset (var, 0, tree_size (var));
     691                 :             : 
     692                 :    74365793 :       imm->prev = imm;
     693                 :    74365793 :       imm->next = imm;
     694                 :    74365793 :       imm->loc.ssa_name = var;
     695                 :             : 
     696                 :             :       /* First put back the right tree node so that the tree checking
     697                 :             :          macros do not complain.  */
     698                 :    74365793 :       TREE_SET_CODE (var, SSA_NAME);
     699                 :             : 
     700                 :             :       /* Restore the version number.  */
     701                 :    74365793 :       SSA_NAME_VERSION (var) = saved_ssa_name_version;
     702                 :             : 
     703                 :             :       /* Note this SSA_NAME is now in the first list.  */
     704                 :    74365793 :       SSA_NAME_IN_FREE_LIST (var) = 1;
     705                 :             : 
     706                 :             :       /* Put in a non-NULL TREE_TYPE so dumping code will not ICE
     707                 :             :          if it happens to come along a released SSA name and tries
     708                 :             :          to inspect its type.  */
     709                 :    74365793 :       TREE_TYPE (var) = error_mark_node;
     710                 :             : 
     711                 :             :       /* And finally queue it so that it will be put on the free list.  */
     712                 :    74365793 :       vec_safe_push (FREE_SSANAMES_QUEUE (fn), var);
     713                 :             :     }
     714                 :             : }
     715                 :             : 
     716                 :             : /* If the alignment of the pointer described by PI is known, return true and
     717                 :             :    store the alignment and the deviation from it into *ALIGNP and *MISALIGNP
     718                 :             :    respectively.  Otherwise return false.  */
     719                 :             : 
     720                 :             : bool
     721                 :    43436399 : get_ptr_info_alignment (struct ptr_info_def *pi, unsigned int *alignp,
     722                 :             :                         unsigned int *misalignp)
     723                 :             : {
     724                 :    43436399 :   if (pi->align)
     725                 :             :     {
     726                 :     5607628 :       *alignp = pi->align;
     727                 :     5607628 :       *misalignp = pi->misalign;
     728                 :     5607628 :       return true;
     729                 :             :     }
     730                 :             :   else
     731                 :             :     return false;
     732                 :             : }
     733                 :             : 
     734                 :             : /* State that the pointer described by PI has unknown alignment.  */
     735                 :             : 
     736                 :             : void
     737                 :    14413724 : mark_ptr_info_alignment_unknown (struct ptr_info_def *pi)
     738                 :             : {
     739                 :    14413724 :   pi->align = 0;
     740                 :    14413724 :   pi->misalign = 0;
     741                 :    14413724 : }
     742                 :             : 
     743                 :             : /* Store the power-of-two byte alignment and the deviation from that
     744                 :             :    alignment of pointer described by PI to ALIOGN and MISALIGN
     745                 :             :    respectively.  */
     746                 :             : 
     747                 :             : void
     748                 :     1504169 : set_ptr_info_alignment (struct ptr_info_def *pi, unsigned int align,
     749                 :             :                             unsigned int misalign)
     750                 :             : {
     751                 :     1504169 :   gcc_checking_assert (align != 0);
     752                 :     1504169 :   gcc_assert ((align & (align - 1)) == 0);
     753                 :     1504169 :   gcc_assert ((misalign & ~(align - 1)) == 0);
     754                 :             : 
     755                 :     1504169 :   pi->align = align;
     756                 :     1504169 :   pi->misalign = misalign;
     757                 :     1504169 : }
     758                 :             : 
     759                 :             : /* If pointer described by PI has known alignment, increase its known
     760                 :             :    misalignment by INCREMENT modulo its current alignment.  */
     761                 :             : 
     762                 :             : void
     763                 :           0 : adjust_ptr_info_misalignment (struct ptr_info_def *pi, poly_uint64 increment)
     764                 :             : {
     765                 :           0 :   if (pi->align != 0)
     766                 :             :     {
     767                 :           0 :       increment += pi->misalign;
     768                 :           0 :       if (!known_misalignment (increment, pi->align, &pi->misalign))
     769                 :             :         {
     770                 :             :           pi->align = known_alignment (increment);
     771                 :             :           pi->misalign = 0;
     772                 :             :         }
     773                 :             :     }
     774                 :           0 : }
     775                 :             : 
     776                 :             : /* Return the alias information associated with pointer T.  It creates a
     777                 :             :    new instance if none existed.  */
     778                 :             : 
     779                 :             : struct ptr_info_def *
     780                 :    34530557 : get_ptr_info (tree t)
     781                 :             : {
     782                 :    34530557 :   struct ptr_info_def *pi;
     783                 :             : 
     784                 :    34530557 :   gcc_assert (POINTER_TYPE_P (TREE_TYPE (t)));
     785                 :             : 
     786                 :    34530557 :   pi = SSA_NAME_PTR_INFO (t);
     787                 :    34530557 :   if (pi == NULL)
     788                 :             :     {
     789                 :    13812731 :       pi = ggc_cleared_alloc<ptr_info_def> ();
     790                 :    13812731 :       pt_solution_reset (&pi->pt);
     791                 :    13812731 :       mark_ptr_info_alignment_unknown (pi);
     792                 :    13812731 :       SSA_NAME_PTR_INFO (t) = pi;
     793                 :             :     }
     794                 :             : 
     795                 :    34530557 :   return pi;
     796                 :             : }
     797                 :             : 
     798                 :             : 
     799                 :             : /* Creates a new SSA name using the template NAME tobe defined by
     800                 :             :    statement STMT in function FN.  */
     801                 :             : 
     802                 :             : tree
     803                 :    17152546 : copy_ssa_name_fn (struct function *fn, tree name, gimple *stmt)
     804                 :             : {
     805                 :    17152546 :   tree new_name;
     806                 :             : 
     807                 :    17152546 :   if (SSA_NAME_VAR (name))
     808                 :    11176769 :     new_name = make_ssa_name_fn (fn, SSA_NAME_VAR (name), stmt);
     809                 :             :   else
     810                 :             :     {
     811                 :     5975777 :       new_name = make_ssa_name_fn (fn, TREE_TYPE (name), stmt);
     812                 :    11951554 :       SET_SSA_NAME_VAR_OR_IDENTIFIER (new_name, SSA_NAME_IDENTIFIER (name));
     813                 :             :     }
     814                 :             : 
     815                 :    17152546 :   return new_name;
     816                 :             : }
     817                 :             : 
     818                 :             : 
     819                 :             : /* Creates a duplicate of the ptr_info_def at PTR_INFO for use by
     820                 :             :    the SSA name NAME.  */
     821                 :             : 
     822                 :             : void
     823                 :     2618506 : duplicate_ssa_name_ptr_info (tree name, struct ptr_info_def *ptr_info)
     824                 :             : {
     825                 :     2618506 :   struct ptr_info_def *new_ptr_info;
     826                 :             : 
     827                 :     2618506 :   gcc_assert (POINTER_TYPE_P (TREE_TYPE (name)));
     828                 :     2618506 :   gcc_assert (!SSA_NAME_PTR_INFO (name));
     829                 :             : 
     830                 :     2618506 :   if (!ptr_info)
     831                 :             :     return;
     832                 :             : 
     833                 :     2618451 :   new_ptr_info = ggc_alloc<ptr_info_def> ();
     834                 :     2618451 :   *new_ptr_info = *ptr_info;
     835                 :             : 
     836                 :     2618451 :   SSA_NAME_PTR_INFO (name) = new_ptr_info;
     837                 :             : }
     838                 :             : 
     839                 :             : void
     840                 :     6917401 : duplicate_ssa_name_range_info (tree name, tree src)
     841                 :             : {
     842                 :     6917401 :   gcc_checking_assert (!POINTER_TYPE_P (TREE_TYPE (src)));
     843                 :     6917401 :   gcc_checking_assert (!range_info_p (name));
     844                 :             : 
     845                 :     6917401 :   if (range_info_p (src))
     846                 :             :     {
     847                 :     6917401 :       value_range src_range (TREE_TYPE (src));
     848                 :     6917401 :       range_info_get_range (src, src_range);
     849                 :     6917401 :       range_info_set_range (name, src_range);
     850                 :     6917401 :     }
     851                 :     6917401 : }
     852                 :             : 
     853                 :             : /* For a SSA copy DEST = SRC duplicate SSA info present on DEST to SRC
     854                 :             :    to preserve it in case DEST is eliminated to SRC.  */
     855                 :             : 
     856                 :             : void
     857                 :    49287758 : maybe_duplicate_ssa_info_at_copy (tree dest, tree src)
     858                 :             : {
     859                 :             :   /* While points-to info is flow-insensitive we have to avoid copying
     860                 :             :      info from not executed regions invoking UB to dominating defs.  */
     861                 :    49287758 :   if (gimple_bb (SSA_NAME_DEF_STMT (src))
     862                 :    49287758 :       != gimple_bb (SSA_NAME_DEF_STMT (dest)))
     863                 :             :     return;
     864                 :             : 
     865                 :    61902981 :   if (POINTER_TYPE_P (TREE_TYPE (dest))
     866                 :    16925721 :       && SSA_NAME_PTR_INFO (dest)
     867                 :    47670770 :       && ! SSA_NAME_PTR_INFO (src))
     868                 :      390038 :     duplicate_ssa_name_ptr_info (src, SSA_NAME_PTR_INFO (dest));
     869                 :    76773990 :   else if (INTEGRAL_TYPE_P (TREE_TYPE (dest))
     870                 :    18527476 :            && SSA_NAME_RANGE_INFO (dest)
     871                 :    39539360 :            && ! SSA_NAME_RANGE_INFO (src))
     872                 :       98741 :     duplicate_ssa_name_range_info (src, dest);
     873                 :             : }
     874                 :             : 
     875                 :             : 
     876                 :             : /* Creates a duplicate of a ssa name NAME tobe defined by statement STMT
     877                 :             :    in function FN.  */
     878                 :             : 
     879                 :             : tree
     880                 :    15411449 : duplicate_ssa_name_fn (struct function *fn, tree name, gimple *stmt)
     881                 :             : {
     882                 :    15411449 :   tree new_name = copy_ssa_name_fn (fn, name, stmt);
     883                 :    15411449 :   if (POINTER_TYPE_P (TREE_TYPE (name)))
     884                 :             :     {
     885                 :     1876858 :       struct ptr_info_def *old_ptr_info = SSA_NAME_PTR_INFO (name);
     886                 :             : 
     887                 :     1876858 :       if (old_ptr_info)
     888                 :     1669099 :         duplicate_ssa_name_ptr_info (new_name, old_ptr_info);
     889                 :             :     }
     890                 :    13534591 :   else if (range_info_p (name))
     891                 :     3542711 :     duplicate_ssa_name_range_info (new_name, name);
     892                 :             : 
     893                 :    15411449 :   return new_name;
     894                 :             : }
     895                 :             : 
     896                 :             : 
     897                 :             : /* Reset all flow sensitive data on NAME such as range-info, nonzero
     898                 :             :    bits and alignment.  */
     899                 :             : 
     900                 :             : void
     901                 :     2890631 : reset_flow_sensitive_info (tree name)
     902                 :             : {
     903                 :     2890631 :   if (POINTER_TYPE_P (TREE_TYPE (name)))
     904                 :             :     {
     905                 :             :       /* points-to info is not flow-sensitive.  */
     906                 :      281938 :       if (SSA_NAME_PTR_INFO (name))
     907                 :             :         {
     908                 :             :           /* [E]VRP can derive context sensitive alignment info and
     909                 :             :              non-nullness properties.  We must reset both.  */
     910                 :      279038 :           mark_ptr_info_alignment_unknown (SSA_NAME_PTR_INFO (name));
     911                 :      279038 :           SSA_NAME_PTR_INFO (name)->pt.null = 1;
     912                 :             :         }
     913                 :             :     }
     914                 :             :   else
     915                 :     2608693 :     SSA_NAME_RANGE_INFO (name) = NULL;
     916                 :     2890631 : }
     917                 :             : 
     918                 :             : /* Clear all flow sensitive data from all statements and PHI definitions
     919                 :             :    in BB.  */
     920                 :             : 
     921                 :             : void
     922                 :     1268374 : reset_flow_sensitive_info_in_bb (basic_block bb)
     923                 :             : {
     924                 :     3759186 :   for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
     925                 :     1222438 :        gsi_next (&gsi))
     926                 :             :     {
     927                 :     1222438 :       gimple *stmt = gsi_stmt (gsi);
     928                 :     1222438 :       ssa_op_iter i;
     929                 :     1222438 :       tree op;
     930                 :     1471684 :       FOR_EACH_SSA_TREE_OPERAND (op, stmt, i, SSA_OP_DEF)
     931                 :      249246 :         reset_flow_sensitive_info (op);
     932                 :             :     }
     933                 :             : 
     934                 :     1287407 :   for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
     935                 :       19033 :        gsi_next (&gsi))
     936                 :             :     {
     937                 :       19033 :       tree phi_def = gimple_phi_result (gsi.phi ());
     938                 :       19033 :       reset_flow_sensitive_info (phi_def);
     939                 :             :     }
     940                 :     1268374 : }
     941                 :             : 
     942                 :             : /* Release all the SSA_NAMEs created by STMT.  */
     943                 :             : 
     944                 :             : void
     945                 :    62796603 : release_defs (gimple *stmt)
     946                 :             : {
     947                 :    62796603 :   tree def;
     948                 :    62796603 :   ssa_op_iter iter;
     949                 :             : 
     950                 :   109170191 :   FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_ALL_DEFS)
     951                 :    46373588 :     if (TREE_CODE (def) == SSA_NAME)
     952                 :    45868756 :       release_ssa_name (def);
     953                 :    62796603 : }
     954                 :             : 
     955                 :             : 
     956                 :             : /* Replace the symbol associated with SSA_NAME with SYM.  */
     957                 :             : 
     958                 :             : void
     959                 :       12461 : replace_ssa_name_symbol (tree ssa_name, tree sym)
     960                 :             : {
     961                 :       12461 :   SET_SSA_NAME_VAR_OR_IDENTIFIER (ssa_name, sym);
     962                 :       12461 :   TREE_TYPE (ssa_name) = TREE_TYPE (sym);
     963                 :       12461 : }
     964                 :             : 
     965                 :             : /* Release the vector of free SSA_NAMEs and compact the vector of SSA_NAMEs
     966                 :             :    that are live.  */
     967                 :             : 
     968                 :             : static void
     969                 :     2663212 : release_free_names_and_compact_live_names (function *fun)
     970                 :             : {
     971                 :     2663212 :   unsigned i, j;
     972                 :     2663212 :   int n = vec_safe_length (FREE_SSANAMES (fun));
     973                 :             : 
     974                 :             :   /* Now release the freelist.  */
     975                 :     2663212 :   vec_free (FREE_SSANAMES (fun));
     976                 :             : 
     977                 :             :   /* And compact the SSA number space.  We make sure to not change the
     978                 :             :      relative order of SSA versions.  */
     979                 :    77506254 :   for (i = 1, j = 1; i < fun->gimple_df->ssa_names->length (); ++i)
     980                 :             :     {
     981                 :    74843042 :       tree name = ssa_name (i);
     982                 :    74843042 :       if (name)
     983                 :             :         {
     984                 :    47897726 :           if (i != j)
     985                 :             :             {
     986                 :    29522659 :               SSA_NAME_VERSION (name) = j;
     987                 :    29522659 :               (*fun->gimple_df->ssa_names)[j] = name;
     988                 :             :             }
     989                 :    47897726 :           j++;
     990                 :             :         }
     991                 :             :     }
     992                 :     2663212 :   fun->gimple_df->ssa_names->truncate (j);
     993                 :             : 
     994                 :     2663212 :   statistics_counter_event (fun, "SSA names released", n);
     995                 :     2663212 :   statistics_counter_event (fun, "SSA name holes removed", i - j);
     996                 :     2663212 :   if (dump_file)
     997                 :         252 :     fprintf (dump_file, "Released %i names, %.2f%%, removed %i holes\n",
     998                 :         252 :              n, n * 100.0 / num_ssa_names, i - j);
     999                 :     2663212 : }
    1000                 :             : 
    1001                 :             : /* Return SSA names that are unused to GGC memory and compact the SSA
    1002                 :             :    version namespace.  This is used to keep footprint of compiler during
    1003                 :             :    interprocedural optimization.  */
    1004                 :             : 
    1005                 :             : namespace {
    1006                 :             : 
    1007                 :             : const pass_data pass_data_release_ssa_names =
    1008                 :             : {
    1009                 :             :   GIMPLE_PASS, /* type */
    1010                 :             :   "release_ssa", /* name */
    1011                 :             :   OPTGROUP_NONE, /* optinfo_flags */
    1012                 :             :   TV_TREE_SSA_OTHER, /* tv_id */
    1013                 :             :   PROP_ssa, /* properties_required */
    1014                 :             :   0, /* properties_provided */
    1015                 :             :   0, /* properties_destroyed */
    1016                 :             :   TODO_remove_unused_locals, /* todo_flags_start */
    1017                 :             :   0, /* todo_flags_finish */
    1018                 :             : };
    1019                 :             : 
    1020                 :             : class pass_release_ssa_names : public gimple_opt_pass
    1021                 :             : {
    1022                 :             : public:
    1023                 :      280114 :   pass_release_ssa_names (gcc::context *ctxt)
    1024                 :      560228 :     : gimple_opt_pass (pass_data_release_ssa_names, ctxt)
    1025                 :             :   {}
    1026                 :             : 
    1027                 :             :   /* opt_pass methods: */
    1028                 :             :   unsigned int execute (function *) final override;
    1029                 :             : 
    1030                 :             : }; // class pass_release_ssa_names
    1031                 :             : 
    1032                 :             : unsigned int
    1033                 :     2663212 : pass_release_ssa_names::execute (function *fun)
    1034                 :             : {
    1035                 :     2663212 :   release_free_names_and_compact_live_names (fun);
    1036                 :     2663212 :   return 0;
    1037                 :             : }
    1038                 :             : 
    1039                 :             : } // anon namespace
    1040                 :             : 
    1041                 :             : gimple_opt_pass *
    1042                 :      280114 : make_pass_release_ssa_names (gcc::context *ctxt)
    1043                 :             : {
    1044                 :      280114 :   return new pass_release_ssa_names (ctxt);
    1045                 :             : }
    1046                 :             : 
    1047                 :             : /* Save and restore of flow sensitive information. */
    1048                 :             : 
    1049                 :             : /* Save off the flow sensitive info from NAME. */
    1050                 :             : 
    1051                 :             : void
    1052                 :     2127057 : flow_sensitive_info_storage::save (tree name)
    1053                 :             : {
    1054                 :     2127057 :   gcc_assert (state == 0);
    1055                 :     2127057 :   if (!POINTER_TYPE_P (TREE_TYPE (name)))
    1056                 :             :     {
    1057                 :     2114793 :       range_info = SSA_NAME_RANGE_INFO (name);
    1058                 :     2114793 :       state = 1;
    1059                 :     2114793 :       return;
    1060                 :             :     }
    1061                 :       12264 :   state = -1;
    1062                 :       12264 :   auto ptr_info = SSA_NAME_PTR_INFO (name);
    1063                 :       12264 :   if (ptr_info)
    1064                 :             :     {
    1065                 :       11642 :       align = ptr_info->align;
    1066                 :       11642 :       misalign = ptr_info->misalign;
    1067                 :       11642 :       null = SSA_NAME_PTR_INFO (name)->pt.null;
    1068                 :             :     }
    1069                 :             :   else
    1070                 :             :     {
    1071                 :         622 :       align = 0;
    1072                 :         622 :       misalign = 0;
    1073                 :         622 :       null = true;
    1074                 :             :     }
    1075                 :             : }
    1076                 :             : 
    1077                 :             : /* Restore the flow sensitive info from NAME. */
    1078                 :             : 
    1079                 :             : void
    1080                 :     2127057 : flow_sensitive_info_storage::restore (tree name)
    1081                 :             : {
    1082                 :     2127057 :   gcc_assert (state != 0);
    1083                 :     2127057 :   if (!POINTER_TYPE_P (TREE_TYPE (name)))
    1084                 :             :     {
    1085                 :     2114793 :       gcc_assert (state == 1);
    1086                 :     2114793 :       SSA_NAME_RANGE_INFO (name) = range_info;
    1087                 :     2114793 :       return;
    1088                 :             :     }
    1089                 :       12264 :   gcc_assert (state == -1);
    1090                 :       12264 :   auto ptr_info = SSA_NAME_PTR_INFO (name);
    1091                 :             :   /* If there was no flow sensitive info on the pointer
    1092                 :             :      just return, there is nothing to restore to.  */
    1093                 :       12264 :   if (!ptr_info)
    1094                 :             :     return;
    1095                 :       11642 :   if (align != 0)
    1096                 :         325 :     set_ptr_info_alignment (ptr_info, align, misalign);
    1097                 :             :   else
    1098                 :       11317 :     mark_ptr_info_alignment_unknown (ptr_info);
    1099                 :       11642 :   SSA_NAME_PTR_INFO (name)->pt.null = null;
    1100                 :             : }
    1101                 :             : 
    1102                 :             : /* Save off the flow sensitive info from NAME.
    1103                 :             :    And reset the flow sensitive info of NAME. */
    1104                 :             : 
    1105                 :             : void
    1106                 :     2127057 : flow_sensitive_info_storage::save_and_clear (tree name)
    1107                 :             : {
    1108                 :     2127057 :   save (name);
    1109                 :     2127057 :   reset_flow_sensitive_info (name);
    1110                 :     2127057 : }
    1111                 :             : 
    1112                 :             : /* Clear the storage. */
    1113                 :             : void
    1114                 :           0 : flow_sensitive_info_storage::clear_storage (void)
    1115                 :             : {
    1116                 :           0 :   state = 0;
    1117                 :           0 : }
        

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