LCOV - code coverage report
Current view: top level - gcc - df-scan.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 85.3 % 1934 1650
Test Date: 2024-04-20 14:03:02 Functions: 90.7 % 97 88
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Scanning of rtl for dataflow analysis.
       2                 :             :    Copyright (C) 1999-2024 Free Software Foundation, Inc.
       3                 :             :    Originally contributed by Michael P. Hayes
       4                 :             :              (m.hayes@elec.canterbury.ac.nz, mhayes@redhat.com)
       5                 :             :    Major rewrite contributed by Danny Berlin (dberlin@dberlin.org)
       6                 :             :              and Kenneth Zadeck (zadeck@naturalbridge.com).
       7                 :             : 
       8                 :             : This file is part of GCC.
       9                 :             : 
      10                 :             : GCC is free software; you can redistribute it and/or modify it under
      11                 :             : the terms of the GNU General Public License as published by the Free
      12                 :             : Software Foundation; either version 3, or (at your option) any later
      13                 :             : version.
      14                 :             : 
      15                 :             : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      16                 :             : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      17                 :             : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      18                 :             : for more details.
      19                 :             : 
      20                 :             : You should have received a copy of the GNU General Public License
      21                 :             : along with GCC; see the file COPYING3.  If not see
      22                 :             : <http://www.gnu.org/licenses/>.  */
      23                 :             : 
      24                 :             : #include "config.h"
      25                 :             : #include "system.h"
      26                 :             : #include "coretypes.h"
      27                 :             : #include "backend.h"
      28                 :             : #include "target.h"
      29                 :             : #include "rtl.h"
      30                 :             : #include "tree.h"
      31                 :             : #include "df.h"
      32                 :             : #include "memmodel.h"
      33                 :             : #include "tm_p.h"
      34                 :             : #include "regs.h"
      35                 :             : #include "emit-rtl.h"  /* FIXME: Can go away once crtl is moved to rtl.h.  */
      36                 :             : #include "dumpfile.h"
      37                 :             : #include "calls.h"
      38                 :             : #include "function-abi.h"
      39                 :             : 
      40                 :             : /* The set of hard registers in eliminables[i].from. */
      41                 :             : 
      42                 :             : static HARD_REG_SET elim_reg_set;
      43                 :             : 
      44                 :             : /* Initialize ur_in and ur_out as if all hard registers were partially
      45                 :             :    available.  */
      46                 :             : 
      47                 :   348798332 : class df_collection_rec
      48                 :             : {
      49                 :             : public:
      50                 :             :   auto_vec<df_ref, 128> def_vec;
      51                 :             :   auto_vec<df_ref, 32> use_vec;
      52                 :             :   auto_vec<df_ref, 32> eq_use_vec;
      53                 :             :   auto_vec<df_mw_hardreg *, 32> mw_vec;
      54                 :             : };
      55                 :             : 
      56                 :             : static void df_ref_record (enum df_ref_class, class df_collection_rec *,
      57                 :             :                            rtx, rtx *,
      58                 :             :                            basic_block, struct df_insn_info *,
      59                 :             :                            enum df_ref_type, int ref_flags);
      60                 :             : static void df_def_record_1 (class df_collection_rec *, rtx *,
      61                 :             :                              basic_block, struct df_insn_info *,
      62                 :             :                              int ref_flags);
      63                 :             : static void df_defs_record (class df_collection_rec *, rtx,
      64                 :             :                             basic_block, struct df_insn_info *,
      65                 :             :                             int ref_flags);
      66                 :             : static void df_uses_record (class df_collection_rec *,
      67                 :             :                             rtx *, enum df_ref_type,
      68                 :             :                             basic_block, struct df_insn_info *,
      69                 :             :                             int ref_flags);
      70                 :             : 
      71                 :             : static void df_install_ref_incremental (df_ref);
      72                 :             : static void df_insn_refs_collect (class df_collection_rec*,
      73                 :             :                                   basic_block, struct df_insn_info *);
      74                 :             : static void df_canonize_collection_rec (class df_collection_rec *);
      75                 :             : 
      76                 :             : static void df_get_regular_block_artificial_uses (bitmap);
      77                 :             : static void df_get_eh_block_artificial_uses (bitmap);
      78                 :             : 
      79                 :             : static void df_record_entry_block_defs (bitmap);
      80                 :             : static void df_record_exit_block_uses (bitmap);
      81                 :             : static void df_get_exit_block_use_set (bitmap);
      82                 :             : static void df_get_entry_block_def_set (bitmap);
      83                 :             : static void df_grow_ref_info (struct df_ref_info *, unsigned int);
      84                 :             : static void df_ref_chain_delete_du_chain (df_ref);
      85                 :             : static void df_ref_chain_delete (df_ref);
      86                 :             : 
      87                 :             : static void df_refs_add_to_chains (class df_collection_rec *,
      88                 :             :                                    basic_block, rtx_insn *, unsigned int);
      89                 :             : 
      90                 :             : static bool df_insn_refs_verify (class df_collection_rec *, basic_block,
      91                 :             :                                  rtx_insn *, bool);
      92                 :             : static void df_entry_block_defs_collect (class df_collection_rec *, bitmap);
      93                 :             : static void df_exit_block_uses_collect (class df_collection_rec *, bitmap);
      94                 :             : static void df_install_ref (df_ref, struct df_reg_info *,
      95                 :             :                             struct df_ref_info *, bool);
      96                 :             : 
      97                 :             : static int df_ref_compare (df_ref, df_ref);
      98                 :             : static int df_ref_ptr_compare (const void *, const void *);
      99                 :             : static int df_mw_compare (const df_mw_hardreg *, const df_mw_hardreg *);
     100                 :             : static int df_mw_ptr_compare (const void *, const void *);
     101                 :             : 
     102                 :             : static void df_insn_info_delete (unsigned int);
     103                 :             : 
     104                 :             : /* Indexed by hardware reg number, is true if that register is ever
     105                 :             :    used in the current function.
     106                 :             : 
     107                 :             :    In df-scan.cc, this is set up to record the hard regs used
     108                 :             :    explicitly.  Reload adds in the hard regs used for holding pseudo
     109                 :             :    regs.  Final uses it to generate the code in the function prologue
     110                 :             :    and epilogue to save and restore registers as needed.  */
     111                 :             : 
     112                 :             : static bool regs_ever_live[FIRST_PSEUDO_REGISTER];
     113                 :             : 
     114                 :             : /* Flags used to tell df_refs_add_to_chains() which vectors it should copy. */
     115                 :             : static const unsigned int copy_defs = 0x1;
     116                 :             : static const unsigned int copy_uses = 0x2;
     117                 :             : static const unsigned int copy_eq_uses = 0x4;
     118                 :             : static const unsigned int copy_mw = 0x8;
     119                 :             : static const unsigned int copy_all = copy_defs | copy_uses | copy_eq_uses
     120                 :             : | copy_mw;
     121                 :             : 
     122                 :             : /*----------------------------------------------------------------------------
     123                 :             :    SCANNING DATAFLOW PROBLEM
     124                 :             : 
     125                 :             :    There are several ways in which scanning looks just like the other
     126                 :             :    dataflow problems.  It shares the all the mechanisms for local info
     127                 :             :    as well as basic block info.  Where it differs is when and how often
     128                 :             :    it gets run.  It also has no need for the iterative solver.
     129                 :             : ----------------------------------------------------------------------------*/
     130                 :             : 
     131                 :             : /* Problem data for the scanning dataflow function.  */
     132                 :             : struct df_scan_problem_data
     133                 :             : {
     134                 :             :   object_allocator<df_base_ref> *ref_base_pool;
     135                 :             :   object_allocator<df_artificial_ref> *ref_artificial_pool;
     136                 :             :   object_allocator<df_regular_ref> *ref_regular_pool;
     137                 :             :   object_allocator<df_insn_info> *insn_pool;
     138                 :             :   object_allocator<df_reg_info> *reg_pool;
     139                 :             :   object_allocator<df_mw_hardreg> *mw_reg_pool;
     140                 :             : 
     141                 :             :   bitmap_obstack reg_bitmaps;
     142                 :             :   bitmap_obstack insn_bitmaps;
     143                 :             : };
     144                 :             : 
     145                 :             : /* Internal function to shut down the scanning problem.  */
     146                 :             : static void
     147                 :     2943663 : df_scan_free_internal (void)
     148                 :             : {
     149                 :     2943663 :   struct df_scan_problem_data *problem_data
     150                 :     2943663 :     = (struct df_scan_problem_data *) df_scan->problem_data;
     151                 :             : 
     152                 :     2943663 :   free (df->def_info.refs);
     153                 :     2943663 :   free (df->def_info.begin);
     154                 :     2943663 :   free (df->def_info.count);
     155                 :     2943663 :   memset (&df->def_info, 0, (sizeof (struct df_ref_info)));
     156                 :             : 
     157                 :     2943663 :   free (df->use_info.refs);
     158                 :     2943663 :   free (df->use_info.begin);
     159                 :     2943663 :   free (df->use_info.count);
     160                 :     2943663 :   memset (&df->use_info, 0, (sizeof (struct df_ref_info)));
     161                 :             : 
     162                 :     2943663 :   free (df->def_regs);
     163                 :     2943663 :   df->def_regs = NULL;
     164                 :     2943663 :   free (df->use_regs);
     165                 :     2943663 :   df->use_regs = NULL;
     166                 :     2943663 :   free (df->eq_use_regs);
     167                 :     2943663 :   df->eq_use_regs = NULL;
     168                 :     2943663 :   df->regs_size = 0;
     169                 :     2943663 :   DF_REG_SIZE (df) = 0;
     170                 :             : 
     171                 :     2943663 :   free (df->insns);
     172                 :     2943663 :   df->insns = NULL;
     173                 :     2943663 :   DF_INSN_SIZE () = 0;
     174                 :             : 
     175                 :     2943663 :   free (df_scan->block_info);
     176                 :     2943663 :   df_scan->block_info = NULL;
     177                 :     2943663 :   df_scan->block_info_size = 0;
     178                 :             : 
     179                 :     2943663 :   bitmap_clear (&df->hardware_regs_used);
     180                 :     2943663 :   bitmap_clear (&df->regular_block_artificial_uses);
     181                 :     2943663 :   bitmap_clear (&df->eh_block_artificial_uses);
     182                 :     2943663 :   BITMAP_FREE (df->entry_block_defs);
     183                 :     2943663 :   BITMAP_FREE (df->exit_block_uses);
     184                 :     2943663 :   bitmap_clear (&df->insns_to_delete);
     185                 :     2943663 :   bitmap_clear (&df->insns_to_rescan);
     186                 :     2943663 :   bitmap_clear (&df->insns_to_notes_rescan);
     187                 :             : 
     188                 :     5887326 :   delete problem_data->ref_base_pool;
     189                 :     5887326 :   delete problem_data->ref_artificial_pool;
     190                 :     5887326 :   delete problem_data->ref_regular_pool;
     191                 :     5887326 :   delete problem_data->insn_pool;
     192                 :     5887326 :   delete problem_data->reg_pool;
     193                 :     5887326 :   delete problem_data->mw_reg_pool;
     194                 :     2943663 :   bitmap_obstack_release (&problem_data->reg_bitmaps);
     195                 :     2943663 :   bitmap_obstack_release (&problem_data->insn_bitmaps);
     196                 :     2943663 :   free (df_scan->problem_data);
     197                 :     2943663 : }
     198                 :             : 
     199                 :             : 
     200                 :             : /* Free basic block info.  */
     201                 :             : 
     202                 :             : static void
     203                 :     5962062 : df_scan_free_bb_info (basic_block bb, void *vbb_info)
     204                 :             : {
     205                 :     5962062 :   struct df_scan_bb_info *bb_info = (struct df_scan_bb_info *) vbb_info;
     206                 :     5962062 :   unsigned int bb_index = bb->index;
     207                 :     5962062 :   rtx_insn *insn;
     208                 :             : 
     209                 :     5962062 :   FOR_BB_INSNS (bb, insn)
     210                 :           0 :     if (INSN_P (insn))
     211                 :           0 :       df_insn_info_delete (INSN_UID (insn));
     212                 :             : 
     213                 :     5962062 :   if (bb_index < df_scan->block_info_size)
     214                 :     5962062 :     bb_info = df_scan_get_bb_info (bb_index);
     215                 :             : 
     216                 :             :   /* Get rid of any artificial uses or defs.  */
     217                 :     5962062 :   df_ref_chain_delete_du_chain (bb_info->artificial_defs);
     218                 :     5962062 :   df_ref_chain_delete_du_chain (bb_info->artificial_uses);
     219                 :    11924124 :   df_ref_chain_delete (bb_info->artificial_defs);
     220                 :    11924124 :   df_ref_chain_delete (bb_info->artificial_uses);
     221                 :     5962062 :   bb_info->artificial_defs = NULL;
     222                 :     5962062 :   bb_info->artificial_uses = NULL;
     223                 :     5962062 : }
     224                 :             : 
     225                 :             : 
     226                 :             : /* Allocate the problem data for the scanning problem.  This should be
     227                 :             :    called when the problem is created or when the entire function is to
     228                 :             :    be rescanned.  */
     229                 :             : void
     230                 :     2943663 : df_scan_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
     231                 :             : {
     232                 :     2943663 :   struct df_scan_problem_data *problem_data;
     233                 :     2943663 :   basic_block bb;
     234                 :             : 
     235                 :             :   /* Given the number of pools, this is really faster than tearing
     236                 :             :      everything apart.  */
     237                 :     2943663 :   if (df_scan->problem_data)
     238                 :     1516896 :     df_scan_free_internal ();
     239                 :             : 
     240                 :     2943663 :   problem_data = XNEW (struct df_scan_problem_data);
     241                 :     2943663 :   df_scan->problem_data = problem_data;
     242                 :     2943663 :   df_scan->computed = true;
     243                 :             : 
     244                 :     5887326 :   problem_data->ref_base_pool = new object_allocator<df_base_ref>
     245                 :     2943663 :     ("df_scan ref base");
     246                 :     5887326 :   problem_data->ref_artificial_pool = new object_allocator<df_artificial_ref>
     247                 :     2943663 :     ("df_scan ref artificial");
     248                 :     5887326 :   problem_data->ref_regular_pool = new object_allocator<df_regular_ref>
     249                 :     2943663 :     ("df_scan ref regular");
     250                 :     5887326 :   problem_data->insn_pool = new object_allocator<df_insn_info>
     251                 :     2943663 :     ("df_scan insn");
     252                 :     5887326 :   problem_data->reg_pool = new object_allocator<df_reg_info>
     253                 :     2943663 :     ("df_scan reg");
     254                 :     5887326 :   problem_data->mw_reg_pool = new object_allocator<df_mw_hardreg>
     255                 :     2943663 :     ("df_scan mw_reg");
     256                 :             : 
     257                 :     2943663 :   bitmap_obstack_initialize (&problem_data->reg_bitmaps);
     258                 :     2943663 :   bitmap_obstack_initialize (&problem_data->insn_bitmaps);
     259                 :             : 
     260                 :     2943663 :   df_grow_reg_info ();
     261                 :             : 
     262                 :     2943663 :   df_grow_insn_info ();
     263                 :     2943663 :   df_grow_bb_info (df_scan);
     264                 :             : 
     265                 :    36726746 :   FOR_ALL_BB_FN (bb, cfun)
     266                 :             :     {
     267                 :    33783083 :       unsigned int bb_index = bb->index;
     268                 :    33783083 :       struct df_scan_bb_info *bb_info = df_scan_get_bb_info (bb_index);
     269                 :    33783083 :       bb_info->artificial_defs = NULL;
     270                 :    33783083 :       bb_info->artificial_uses = NULL;
     271                 :             :     }
     272                 :             : 
     273                 :     2943663 :   bitmap_initialize (&df->hardware_regs_used, &problem_data->reg_bitmaps);
     274                 :     2943663 :   bitmap_initialize (&df->regular_block_artificial_uses, &problem_data->reg_bitmaps);
     275                 :     2943663 :   bitmap_initialize (&df->eh_block_artificial_uses, &problem_data->reg_bitmaps);
     276                 :     2943663 :   df->entry_block_defs = BITMAP_ALLOC (&problem_data->reg_bitmaps);
     277                 :     2943663 :   df->exit_block_uses = BITMAP_ALLOC (&problem_data->reg_bitmaps);
     278                 :     2943663 :   bitmap_initialize (&df->insns_to_delete, &problem_data->insn_bitmaps);
     279                 :     2943663 :   bitmap_initialize (&df->insns_to_rescan, &problem_data->insn_bitmaps);
     280                 :     2943663 :   bitmap_initialize (&df->insns_to_notes_rescan, &problem_data->insn_bitmaps);
     281                 :     2943663 :   df_scan->optional_p = false;
     282                 :     2943663 : }
     283                 :             : 
     284                 :             : 
     285                 :             : /* Free all of the data associated with the scan problem.  */
     286                 :             : 
     287                 :             : static void
     288                 :     1426767 : df_scan_free (void)
     289                 :             : {
     290                 :     1426767 :   if (df_scan->problem_data)
     291                 :     1426767 :     df_scan_free_internal ();
     292                 :             : 
     293                 :     1426767 :   if (df->blocks_to_analyze)
     294                 :             :     {
     295                 :           0 :       BITMAP_FREE (df->blocks_to_analyze);
     296                 :           0 :       df->blocks_to_analyze = NULL;
     297                 :             :     }
     298                 :             : 
     299                 :     1426767 :   free (df_scan);
     300                 :     1426767 : }
     301                 :             : 
     302                 :             : /* Dump the preamble for DF_SCAN dump. */
     303                 :             : static void
     304                 :        3830 : df_scan_start_dump (FILE *file ATTRIBUTE_UNUSED)
     305                 :             : {
     306                 :        3830 :   int i;
     307                 :        3830 :   int dcount = 0;
     308                 :        3830 :   int ucount = 0;
     309                 :        3830 :   int ecount = 0;
     310                 :        3830 :   int icount = 0;
     311                 :        3830 :   int ccount = 0;
     312                 :        3830 :   basic_block bb;
     313                 :        3830 :   rtx_insn *insn;
     314                 :             : 
     315                 :        3830 :   fprintf (file, ";;  fully invalidated by EH \t");
     316                 :        3830 :   df_print_regset
     317                 :        3830 :     (file, bitmap_view<HARD_REG_SET> (eh_edge_abi.full_reg_clobbers ()));
     318                 :        3830 :   fprintf (file, ";;  hardware regs used \t");
     319                 :        3830 :   df_print_regset (file, &df->hardware_regs_used);
     320                 :        3830 :   fprintf (file, ";;  regular block artificial uses \t");
     321                 :        3830 :   df_print_regset (file, &df->regular_block_artificial_uses);
     322                 :        3830 :   fprintf (file, ";;  eh block artificial uses \t");
     323                 :        3830 :   df_print_regset (file, &df->eh_block_artificial_uses);
     324                 :        3830 :   fprintf (file, ";;  entry block defs \t");
     325                 :        3830 :   df_print_regset (file, df->entry_block_defs);
     326                 :        3830 :   fprintf (file, ";;  exit block uses \t");
     327                 :        3830 :   df_print_regset (file, df->exit_block_uses);
     328                 :        3830 :   fprintf (file, ";;  regs ever live \t");
     329                 :      360020 :   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
     330                 :      352360 :     if (df_regs_ever_live_p (i))
     331                 :       18973 :       fprintf (file, " %d [%s]", i, reg_names[i]);
     332                 :        3830 :   fprintf (file, "\n;;  ref usage \t");
     333                 :             : 
     334                 :      466597 :   for (i = 0; i < (int)df->regs_inited; i++)
     335                 :      462767 :     if (DF_REG_DEF_COUNT (i) || DF_REG_USE_COUNT (i) || DF_REG_EQ_USE_COUNT (i))
     336                 :             :       {
     337                 :      208832 :         const char * sep = "";
     338                 :             : 
     339                 :      208832 :         fprintf (file, "r%d={", i);
     340                 :      208832 :         if (DF_REG_DEF_COUNT (i))
     341                 :             :           {
     342                 :      208818 :             fprintf (file, "%dd", DF_REG_DEF_COUNT (i));
     343                 :      208818 :             sep = ",";
     344                 :      208818 :             dcount += DF_REG_DEF_COUNT (i);
     345                 :             :           }
     346                 :      208832 :         if (DF_REG_USE_COUNT (i))
     347                 :             :           {
     348                 :       50051 :             fprintf (file, "%s%du", sep, DF_REG_USE_COUNT (i));
     349                 :       50051 :             sep = ",";
     350                 :       50051 :             ucount += DF_REG_USE_COUNT (i);
     351                 :             :           }
     352                 :      208832 :         if (DF_REG_EQ_USE_COUNT (i))
     353                 :             :           {
     354                 :        2502 :             fprintf (file, "%s%de", sep, DF_REG_EQ_USE_COUNT (i));
     355                 :        2502 :             ecount += DF_REG_EQ_USE_COUNT (i);
     356                 :             :           }
     357                 :      208832 :         fprintf (file, "} ");
     358                 :             :       }
     359                 :             : 
     360                 :       27941 :   FOR_EACH_BB_FN (bb, cfun)
     361                 :      186756 :     FOR_BB_INSNS (bb, insn)
     362                 :      162645 :       if (INSN_P (insn))
     363                 :             :         {
     364                 :      113033 :           if (CALL_P (insn))
     365                 :        6829 :             ccount++;
     366                 :             :           else
     367                 :      106204 :             icount++;
     368                 :             :         }
     369                 :             : 
     370                 :        3830 :   fprintf (file, "\n;;    total ref usage %d{%dd,%du,%de}"
     371                 :             :                  " in %d{%d regular + %d call} insns.\n",
     372                 :        3830 :                  dcount + ucount + ecount, dcount, ucount, ecount,
     373                 :             :                  icount + ccount, icount, ccount);
     374                 :        3830 : }
     375                 :             : 
     376                 :             : /* Dump the bb_info for a given basic block. */
     377                 :             : static void
     378                 :        5200 : df_scan_start_block (basic_block bb, FILE *file)
     379                 :             : {
     380                 :        5200 :   struct df_scan_bb_info *bb_info
     381                 :        5200 :     = df_scan_get_bb_info (bb->index);
     382                 :             : 
     383                 :        5200 :   if (bb_info)
     384                 :             :     {
     385                 :        5200 :       fprintf (file, ";; bb %d artificial_defs: ", bb->index);
     386                 :        5200 :       df_refs_chain_dump (bb_info->artificial_defs, true, file);
     387                 :        5200 :       fprintf (file, "\n;; bb %d artificial_uses: ", bb->index);
     388                 :        5200 :       df_refs_chain_dump (bb_info->artificial_uses, true, file);
     389                 :        5200 :       fprintf (file, "\n");
     390                 :             :     }
     391                 :             : #if 0
     392                 :             :   {
     393                 :             :     rtx_insn *insn;
     394                 :             :     FOR_BB_INSNS (bb, insn)
     395                 :             :       if (INSN_P (insn))
     396                 :             :         df_insn_debug (insn, false, file);
     397                 :             :   }
     398                 :             : #endif
     399                 :        5200 : }
     400                 :             : 
     401                 :             : static const struct df_problem problem_SCAN =
     402                 :             : {
     403                 :             :   DF_SCAN,                    /* Problem id.  */
     404                 :             :   DF_NONE,                    /* Direction.  */
     405                 :             :   df_scan_alloc,              /* Allocate the problem specific data.  */
     406                 :             :   NULL,                       /* Reset global information.  */
     407                 :             :   df_scan_free_bb_info,       /* Free basic block info.  */
     408                 :             :   NULL,                       /* Local compute function.  */
     409                 :             :   NULL,                       /* Init the solution specific data.  */
     410                 :             :   NULL,                       /* Iterative solver.  */
     411                 :             :   NULL,                       /* Confluence operator 0.  */
     412                 :             :   NULL,                       /* Confluence operator n.  */
     413                 :             :   NULL,                       /* Transfer function.  */
     414                 :             :   NULL,                       /* Finalize function.  */
     415                 :             :   df_scan_free,               /* Free all of the problem information.  */
     416                 :             :   NULL,                       /* Remove this problem from the stack of dataflow problems.  */
     417                 :             :   df_scan_start_dump,         /* Debugging.  */
     418                 :             :   df_scan_start_block,        /* Debugging start block.  */
     419                 :             :   NULL,                       /* Debugging end block.  */
     420                 :             :   NULL,                       /* Debugging start insn.  */
     421                 :             :   NULL,                       /* Debugging end insn.  */
     422                 :             :   NULL,                       /* Incremental solution verify start.  */
     423                 :             :   NULL,                       /* Incremental solution verify end.  */
     424                 :             :   NULL,                       /* Dependent problem.  */
     425                 :             :   sizeof (struct df_scan_bb_info),/* Size of entry of block_info array.  */
     426                 :             :   TV_DF_SCAN,                 /* Timing variable.  */
     427                 :             :   false                       /* Reset blocks on dropping out of blocks_to_analyze.  */
     428                 :             : };
     429                 :             : 
     430                 :             : 
     431                 :             : /* Create a new DATAFLOW instance and add it to an existing instance
     432                 :             :    of DF.  The returned structure is what is used to get at the
     433                 :             :    solution.  */
     434                 :             : 
     435                 :             : void
     436                 :     1426767 : df_scan_add_problem (void)
     437                 :             : {
     438                 :     1426767 :   df_add_problem (&problem_SCAN);
     439                 :     1426767 : }
     440                 :             : 
     441                 :             : 
     442                 :             : /*----------------------------------------------------------------------------
     443                 :             :    Storage Allocation Utilities
     444                 :             : ----------------------------------------------------------------------------*/
     445                 :             : 
     446                 :             : 
     447                 :             : /* First, grow the reg_info information.  If the current size is less than
     448                 :             :    the number of pseudos, grow to 25% more than the number of
     449                 :             :    pseudos.
     450                 :             : 
     451                 :             :    Second, assure that all of the slots up to max_reg_num have been
     452                 :             :    filled with reg_info structures.  */
     453                 :             : 
     454                 :             : void
     455                 :   340154818 : df_grow_reg_info (void)
     456                 :             : {
     457                 :   340154818 :   unsigned int max_reg = max_reg_num ();
     458                 :   340154818 :   unsigned int new_size = max_reg;
     459                 :   340154818 :   struct df_scan_problem_data *problem_data
     460                 :   340154818 :     = (struct df_scan_problem_data *) df_scan->problem_data;
     461                 :   340154818 :   unsigned int i;
     462                 :             : 
     463                 :   340154818 :   if (df->regs_size < new_size)
     464                 :             :     {
     465                 :     2981192 :       new_size += new_size / 4;
     466                 :     2981192 :       df->def_regs = XRESIZEVEC (struct df_reg_info *, df->def_regs, new_size);
     467                 :     2981192 :       df->use_regs = XRESIZEVEC (struct df_reg_info *, df->use_regs, new_size);
     468                 :     2981192 :       df->eq_use_regs = XRESIZEVEC (struct df_reg_info *, df->eq_use_regs,
     469                 :             :                                     new_size);
     470                 :     2981192 :       df->def_info.begin = XRESIZEVEC (unsigned, df->def_info.begin, new_size);
     471                 :     2981192 :       df->def_info.count = XRESIZEVEC (unsigned, df->def_info.count, new_size);
     472                 :     2981192 :       df->use_info.begin = XRESIZEVEC (unsigned, df->use_info.begin, new_size);
     473                 :     2981192 :       df->use_info.count = XRESIZEVEC (unsigned, df->use_info.count, new_size);
     474                 :     2981192 :       df->regs_size = new_size;
     475                 :             :     }
     476                 :             : 
     477                 :   757364916 :   for (i = df->regs_inited; i < max_reg; i++)
     478                 :             :     {
     479                 :   417210098 :       struct df_reg_info *reg_info;
     480                 :             : 
     481                 :             :       // TODO
     482                 :   417210098 :       reg_info = problem_data->reg_pool->allocate ();
     483                 :   417210098 :       memset (reg_info, 0, sizeof (struct df_reg_info));
     484                 :   417210098 :       df->def_regs[i] = reg_info;
     485                 :   417210098 :       reg_info = problem_data->reg_pool->allocate ();
     486                 :   417210098 :       memset (reg_info, 0, sizeof (struct df_reg_info));
     487                 :   417210098 :       df->use_regs[i] = reg_info;
     488                 :   417210098 :       reg_info = problem_data->reg_pool->allocate ();
     489                 :   417210098 :       memset (reg_info, 0, sizeof (struct df_reg_info));
     490                 :   417210098 :       df->eq_use_regs[i] = reg_info;
     491                 :   417210098 :       df->def_info.begin[i] = 0;
     492                 :   417210098 :       df->def_info.count[i] = 0;
     493                 :   417210098 :       df->use_info.begin[i] = 0;
     494                 :   417210098 :       df->use_info.count[i] = 0;
     495                 :             :     }
     496                 :             : 
     497                 :   340154818 :   df->regs_inited = max_reg;
     498                 :   340154818 : }
     499                 :             : 
     500                 :             : 
     501                 :             : /* Grow the ref information.  */
     502                 :             : 
     503                 :             : static void
     504                 :     5568211 : df_grow_ref_info (struct df_ref_info *ref_info, unsigned int new_size)
     505                 :             : {
     506                 :     5568211 :   if (ref_info->refs_size < new_size)
     507                 :             :     {
     508                 :     5568211 :       ref_info->refs = XRESIZEVEC (df_ref, ref_info->refs, new_size);
     509                 :     5568211 :       memset (ref_info->refs + ref_info->refs_size, 0,
     510                 :     5568211 :               (new_size - ref_info->refs_size) *sizeof (df_ref));
     511                 :     5568211 :       ref_info->refs_size = new_size;
     512                 :             :     }
     513                 :     5568211 : }
     514                 :             : 
     515                 :             : 
     516                 :             : /* Check and grow the ref information if necessary.  This routine
     517                 :             :    guarantees total_size + BITMAP_ADDEND amount of entries in refs
     518                 :             :    array.  It updates ref_info->refs_size only and does not change
     519                 :             :    ref_info->total_size.  */
     520                 :             : 
     521                 :             : static void
     522                 :     6717051 : df_check_and_grow_ref_info (struct df_ref_info *ref_info,
     523                 :             :                             unsigned bitmap_addend)
     524                 :             : {
     525                 :     6717051 :   if (ref_info->refs_size < ref_info->total_size + bitmap_addend)
     526                 :             :     {
     527                 :     5568211 :       int new_size = ref_info->total_size + bitmap_addend;
     528                 :     5568211 :       new_size += ref_info->total_size / 4;
     529                 :     5568211 :       df_grow_ref_info (ref_info, new_size);
     530                 :             :     }
     531                 :     6717051 : }
     532                 :             : 
     533                 :             : 
     534                 :             : /* Grow the ref information.  If the current size is less than the
     535                 :             :    number of instructions, grow to 25% more than the number of
     536                 :             :    instructions.  */
     537                 :             : 
     538                 :             : void
     539                 :   397244215 : df_grow_insn_info (void)
     540                 :             : {
     541                 :   397244215 :   unsigned int new_size = get_max_uid () + 1;
     542                 :   397244215 :   if (DF_INSN_SIZE () < new_size)
     543                 :             :     {
     544                 :     4138825 :       new_size += new_size / 4;
     545                 :     4138825 :       df->insns = XRESIZEVEC (struct df_insn_info *, df->insns, new_size);
     546                 :     4138825 :       memset (df->insns + df->insns_size, 0,
     547                 :     4138825 :               (new_size - DF_INSN_SIZE ()) *sizeof (struct df_insn_info *));
     548                 :     4138825 :       DF_INSN_SIZE () = new_size;
     549                 :             :     }
     550                 :   397244215 : }
     551                 :             : 
     552                 :             : 
     553                 :             : 
     554                 :             : 
     555                 :             : /*----------------------------------------------------------------------------
     556                 :             :    PUBLIC INTERFACES FOR SMALL GRAIN CHANGES TO SCANNING.
     557                 :             : ----------------------------------------------------------------------------*/
     558                 :             : 
     559                 :             : /* Rescan all of the block_to_analyze or all of the blocks in the
     560                 :             :    function if df_set_blocks if blocks_to_analyze is NULL;  */
     561                 :             : 
     562                 :             : void
     563                 :     2943663 : df_scan_blocks (void)
     564                 :             : {
     565                 :     2943663 :   basic_block bb;
     566                 :             : 
     567                 :     2943663 :   df->def_info.ref_order = DF_REF_ORDER_NO_TABLE;
     568                 :     2943663 :   df->use_info.ref_order = DF_REF_ORDER_NO_TABLE;
     569                 :             : 
     570                 :     2943663 :   df_get_regular_block_artificial_uses (&df->regular_block_artificial_uses);
     571                 :     2943663 :   df_get_eh_block_artificial_uses (&df->eh_block_artificial_uses);
     572                 :             : 
     573                 :     2943663 :   bitmap_ior_into (&df->eh_block_artificial_uses,
     574                 :     2943663 :                    &df->regular_block_artificial_uses);
     575                 :             : 
     576                 :             :   /* ENTRY and EXIT blocks have special defs/uses.  */
     577                 :     2943663 :   df_get_entry_block_def_set (df->entry_block_defs);
     578                 :     2943663 :   df_record_entry_block_defs (df->entry_block_defs);
     579                 :     2943663 :   df_get_exit_block_use_set (df->exit_block_uses);
     580                 :     2943663 :   df_record_exit_block_uses (df->exit_block_uses);
     581                 :     2943663 :   df_set_bb_dirty (BASIC_BLOCK_FOR_FN (cfun, ENTRY_BLOCK));
     582                 :     2943663 :   df_set_bb_dirty (BASIC_BLOCK_FOR_FN (cfun, EXIT_BLOCK));
     583                 :             : 
     584                 :             :   /* Regular blocks */
     585                 :    30839420 :   FOR_EACH_BB_FN (bb, cfun)
     586                 :             :     {
     587                 :    27895757 :       unsigned int bb_index = bb->index;
     588                 :    27895757 :       df_bb_refs_record (bb_index, true);
     589                 :             :     }
     590                 :     2943663 : }
     591                 :             : 
     592                 :             : /* Create new refs under address LOC within INSN.  This function is
     593                 :             :    only used externally.  REF_FLAGS must be either 0 or DF_REF_IN_NOTE,
     594                 :             :    depending on whether LOC is inside PATTERN (INSN) or a note.  */
     595                 :             : 
     596                 :             : void
     597                 :           0 : df_uses_create (rtx *loc, rtx_insn *insn, int ref_flags)
     598                 :             : {
     599                 :           0 :   gcc_assert (!(ref_flags & ~DF_REF_IN_NOTE));
     600                 :           0 :   df_uses_record (NULL, loc, DF_REF_REG_USE,
     601                 :           0 :                   BLOCK_FOR_INSN (insn),
     602                 :           0 :                   DF_INSN_INFO_GET (insn),
     603                 :             :                   ref_flags);
     604                 :           0 : }
     605                 :             : 
     606                 :             : static void
     607                 :           0 : df_install_ref_incremental (df_ref ref)
     608                 :             : {
     609                 :           0 :   struct df_reg_info **reg_info;
     610                 :           0 :   struct df_ref_info *ref_info;
     611                 :           0 :   df_ref *ref_ptr;
     612                 :           0 :   bool add_to_table;
     613                 :             : 
     614                 :           0 :   rtx_insn *insn = DF_REF_INSN (ref);
     615                 :           0 :   basic_block bb = BLOCK_FOR_INSN (insn);
     616                 :             : 
     617                 :           0 :   if (DF_REF_REG_DEF_P (ref))
     618                 :             :     {
     619                 :           0 :       reg_info = df->def_regs;
     620                 :           0 :       ref_info = &df->def_info;
     621                 :           0 :       ref_ptr = &DF_INSN_DEFS (insn);
     622                 :           0 :       add_to_table = ref_info->ref_order != DF_REF_ORDER_NO_TABLE;
     623                 :             :     }
     624                 :           0 :   else if (DF_REF_FLAGS (ref) & DF_REF_IN_NOTE)
     625                 :             :     {
     626                 :           0 :       reg_info = df->eq_use_regs;
     627                 :           0 :       ref_info = &df->use_info;
     628                 :           0 :       ref_ptr = &DF_INSN_EQ_USES (insn);
     629                 :           0 :       switch (ref_info->ref_order)
     630                 :             :         {
     631                 :             :         case DF_REF_ORDER_UNORDERED_WITH_NOTES:
     632                 :             :         case DF_REF_ORDER_BY_REG_WITH_NOTES:
     633                 :             :         case DF_REF_ORDER_BY_INSN_WITH_NOTES:
     634                 :             :           add_to_table = true;
     635                 :             :           break;
     636                 :           0 :         default:
     637                 :           0 :           add_to_table = false;
     638                 :           0 :           break;
     639                 :             :         }
     640                 :             :     }
     641                 :             :   else
     642                 :             :     {
     643                 :           0 :       reg_info = df->use_regs;
     644                 :           0 :       ref_info = &df->use_info;
     645                 :           0 :       ref_ptr = &DF_INSN_USES (insn);
     646                 :           0 :       add_to_table = ref_info->ref_order != DF_REF_ORDER_NO_TABLE;
     647                 :             :     }
     648                 :             : 
     649                 :             :   /* Do not add if ref is not in the right blocks.  */
     650                 :           0 :   if (add_to_table && df->analyze_subset)
     651                 :           0 :     add_to_table = bitmap_bit_p (df->blocks_to_analyze, bb->index);
     652                 :             : 
     653                 :           0 :   df_install_ref (ref, reg_info[DF_REF_REGNO (ref)], ref_info, add_to_table);
     654                 :             : 
     655                 :           0 :   if (add_to_table)
     656                 :           0 :     switch (ref_info->ref_order)
     657                 :             :       {
     658                 :           0 :       case DF_REF_ORDER_UNORDERED_WITH_NOTES:
     659                 :           0 :       case DF_REF_ORDER_BY_REG_WITH_NOTES:
     660                 :           0 :       case DF_REF_ORDER_BY_INSN_WITH_NOTES:
     661                 :           0 :         ref_info->ref_order = DF_REF_ORDER_UNORDERED_WITH_NOTES;
     662                 :           0 :         break;
     663                 :           0 :       default:
     664                 :           0 :         ref_info->ref_order = DF_REF_ORDER_UNORDERED;
     665                 :           0 :         break;
     666                 :             :       }
     667                 :             : 
     668                 :           0 :   while (*ref_ptr && df_ref_compare (*ref_ptr, ref) < 0)
     669                 :           0 :     ref_ptr = &DF_REF_NEXT_LOC (*ref_ptr);
     670                 :             : 
     671                 :           0 :   DF_REF_NEXT_LOC (ref) = *ref_ptr;
     672                 :           0 :   *ref_ptr = ref;
     673                 :             : 
     674                 :             : #if 0
     675                 :             :   if (dump_file)
     676                 :             :     {
     677                 :             :       fprintf (dump_file, "adding ref ");
     678                 :             :       df_ref_debug (ref, dump_file);
     679                 :             :     }
     680                 :             : #endif
     681                 :             :   /* By adding the ref directly, df_insn_rescan my not find any
     682                 :             :      differences even though the block will have changed.  So we need
     683                 :             :      to mark the block dirty ourselves.  */
     684                 :           0 :   if (!DEBUG_INSN_P (DF_REF_INSN (ref)))
     685                 :           0 :     df_set_bb_dirty (bb);
     686                 :           0 : }
     687                 :             : 
     688                 :             : 
     689                 :             : 
     690                 :             : /*----------------------------------------------------------------------------
     691                 :             :    UTILITIES TO CREATE AND DESTROY REFS AND CHAINS.
     692                 :             : ----------------------------------------------------------------------------*/
     693                 :             : 
     694                 :             : static void
     695                 :  5604192708 : df_free_ref (df_ref ref)
     696                 :             : {
     697                 :  5604192708 :   struct df_scan_problem_data *problem_data
     698                 :  5604192708 :     = (struct df_scan_problem_data *) df_scan->problem_data;
     699                 :             : 
     700                 :  5604192708 :   switch (DF_REF_CLASS (ref))
     701                 :             :     {
     702                 :  4204668035 :     case DF_REF_BASE:
     703                 :  4204668035 :       problem_data->ref_base_pool->remove ((df_base_ref *) (ref));
     704                 :  4204668035 :       break;
     705                 :             : 
     706                 :   328426378 :     case DF_REF_ARTIFICIAL:
     707                 :   328426378 :       problem_data->ref_artificial_pool->remove
     708                 :   328426378 :         ((df_artificial_ref *) (ref));
     709                 :   328426378 :       break;
     710                 :             : 
     711                 :  1071098295 :     case DF_REF_REGULAR:
     712                 :  1071098295 :       problem_data->ref_regular_pool->remove
     713                 :  1071098295 :         ((df_regular_ref *) (ref));
     714                 :  1071098295 :       break;
     715                 :             :     }
     716                 :  5604192708 : }
     717                 :             : 
     718                 :             : 
     719                 :             : /* Unlink and delete REF at the reg_use, reg_eq_use or reg_def chain.
     720                 :             :    Also delete the def-use or use-def chain if it exists.  */
     721                 :             : 
     722                 :             : static void
     723                 :   253005862 : df_reg_chain_unlink (df_ref ref)
     724                 :             : {
     725                 :   253005862 :   df_ref next = DF_REF_NEXT_REG (ref);
     726                 :   253005862 :   df_ref prev = DF_REF_PREV_REG (ref);
     727                 :   253005862 :   int id = DF_REF_ID (ref);
     728                 :   253005862 :   struct df_reg_info *reg_info;
     729                 :   253005862 :   df_ref *refs = NULL;
     730                 :             : 
     731                 :   253005862 :   if (DF_REF_REG_DEF_P (ref))
     732                 :             :     {
     733                 :   121763641 :       int regno = DF_REF_REGNO (ref);
     734                 :   121763641 :       reg_info = DF_REG_DEF_GET (regno);
     735                 :   121763641 :       refs = df->def_info.refs;
     736                 :             :     }
     737                 :             :   else
     738                 :             :     {
     739                 :   131242221 :       if (DF_REF_FLAGS (ref) & DF_REF_IN_NOTE)
     740                 :             :         {
     741                 :    12632085 :           reg_info = DF_REG_EQ_USE_GET (DF_REF_REGNO (ref));
     742                 :    12632085 :           switch (df->use_info.ref_order)
     743                 :             :             {
     744                 :           0 :             case DF_REF_ORDER_UNORDERED_WITH_NOTES:
     745                 :           0 :             case DF_REF_ORDER_BY_REG_WITH_NOTES:
     746                 :           0 :             case DF_REF_ORDER_BY_INSN_WITH_NOTES:
     747                 :           0 :               refs = df->use_info.refs;
     748                 :           0 :               break;
     749                 :             :             default:
     750                 :             :               break;
     751                 :             :             }
     752                 :             :         }
     753                 :             :       else
     754                 :             :         {
     755                 :   118610136 :           reg_info = DF_REG_USE_GET (DF_REF_REGNO (ref));
     756                 :   118610136 :           refs = df->use_info.refs;
     757                 :             :         }
     758                 :             :     }
     759                 :             : 
     760                 :   240373777 :   if (refs)
     761                 :             :     {
     762                 :     1109382 :       if (df->analyze_subset)
     763                 :             :         {
     764                 :      529631 :           if (bitmap_bit_p (df->blocks_to_analyze, DF_REF_BBNO (ref)))
     765                 :      297804 :             refs[id] = NULL;
     766                 :             :         }
     767                 :             :       else
     768                 :      579751 :         refs[id] = NULL;
     769                 :             :     }
     770                 :             : 
     771                 :             :   /* Delete any def-use or use-def chains that start here. It is
     772                 :             :      possible that there is trash in this field.  This happens for
     773                 :             :      insns that have been deleted when rescanning has been deferred
     774                 :             :      and the chain problem has also been deleted.  The chain tear down
     775                 :             :      code skips deleted insns.  */
     776                 :   253005862 :   if (df_chain && DF_REF_CHAIN (ref))
     777                 :           0 :     df_chain_unlink (ref);
     778                 :             : 
     779                 :   253005862 :   reg_info->n_refs--;
     780                 :   253005862 :   if (DF_REF_FLAGS_IS_SET (ref, DF_HARD_REG_LIVE))
     781                 :             :     {
     782                 :    75420778 :       gcc_assert (DF_REF_REGNO (ref) < FIRST_PSEUDO_REGISTER);
     783                 :    75420778 :       df->hard_regs_live_count[DF_REF_REGNO (ref)]--;
     784                 :             :     }
     785                 :             : 
     786                 :             :   /* Unlink from the reg chain.  If there is no prev, this is the
     787                 :             :      first of the list.  If not, just join the next and prev.  */
     788                 :   253005862 :   if (prev)
     789                 :   175577859 :     DF_REF_NEXT_REG (prev) = next;
     790                 :             :   else
     791                 :             :     {
     792                 :    77428003 :       gcc_assert (reg_info->reg_chain == ref);
     793                 :    77428003 :       reg_info->reg_chain = next;
     794                 :             :     }
     795                 :   253005862 :   if (next)
     796                 :   152962251 :     DF_REF_PREV_REG (next) = prev;
     797                 :             : 
     798                 :   253005862 :   df_free_ref (ref);
     799                 :   253005862 : }
     800                 :             : 
     801                 :             : /* Initialize INSN_INFO to describe INSN.  */
     802                 :             : 
     803                 :             : static void
     804                 :   403916450 : df_insn_info_init_fields (df_insn_info *insn_info, rtx_insn *insn)
     805                 :             : {
     806                 :   403916450 :   memset (insn_info, 0, sizeof (struct df_insn_info));
     807                 :   403916450 :   insn_info->insn = insn;
     808                 :           0 : }
     809                 :             : 
     810                 :             : /* Create the insn record for INSN.  If there was one there, zero it
     811                 :             :    out.  */
     812                 :             : 
     813                 :             : struct df_insn_info *
     814                 :   359466678 : df_insn_create_insn_record (rtx_insn *insn)
     815                 :             : {
     816                 :   359466678 :   struct df_scan_problem_data *problem_data
     817                 :   359466678 :     = (struct df_scan_problem_data *) df_scan->problem_data;
     818                 :   359466678 :   struct df_insn_info *insn_rec;
     819                 :             : 
     820                 :   359466678 :   df_grow_insn_info ();
     821                 :   359466678 :   insn_rec = DF_INSN_INFO_GET (insn);
     822                 :   359466678 :   if (!insn_rec)
     823                 :             :     {
     824                 :   359466678 :       insn_rec = problem_data->insn_pool->allocate ();
     825                 :   359466678 :       DF_INSN_INFO_SET (insn, insn_rec);
     826                 :             :     }
     827                 :   359466678 :   df_insn_info_init_fields (insn_rec, insn);
     828                 :   359466678 :   return insn_rec;
     829                 :             : }
     830                 :             : 
     831                 :             : 
     832                 :             : /* Delete all du chain (DF_REF_CHAIN()) of all refs in the ref chain.  */
     833                 :             : 
     834                 :             : static void
     835                 :    16666310 : df_ref_chain_delete_du_chain (df_ref ref)
     836                 :             : {
     837                 :    61195246 :   for (; ref; ref = DF_REF_NEXT_LOC (ref))
     838                 :             :     /* CHAIN is allocated by DF_CHAIN. So make sure to
     839                 :             :        pass df_scan instance for the problem.  */
     840                 :    44528936 :     if (DF_REF_CHAIN (ref))
     841                 :      540379 :       df_chain_unlink (ref);
     842                 :    16666310 : }
     843                 :             : 
     844                 :             : 
     845                 :             : /* Delete all refs in the ref chain.  */
     846                 :             : 
     847                 :             : static void
     848                 :   400954734 : df_ref_chain_delete (df_ref ref)
     849                 :             : {
     850                 :   400954734 :   df_ref next;
     851                 :   647998534 :   for (; ref; ref = next)
     852                 :             :     {
     853                 :   253005862 :       next = DF_REF_NEXT_LOC (ref);
     854                 :   253005862 :       df_reg_chain_unlink (ref);
     855                 :             :     }
     856                 :           0 : }
     857                 :             : 
     858                 :             : 
     859                 :             : /* Delete the hardreg chain.  */
     860                 :             : 
     861                 :             : static void
     862                 :   121407668 : df_mw_hardreg_chain_delete (struct df_mw_hardreg *hardregs)
     863                 :             : {
     864                 :   121407668 :   struct df_scan_problem_data *problem_data
     865                 :   121407668 :     = (struct df_scan_problem_data *) df_scan->problem_data;
     866                 :   121407668 :   df_mw_hardreg *next;
     867                 :             : 
     868                 :   123955571 :   for (; hardregs; hardregs = next)
     869                 :             :     {
     870                 :     2547903 :       next = DF_MWS_NEXT (hardregs);
     871                 :     2547903 :       problem_data->mw_reg_pool->remove (hardregs);
     872                 :             :     }
     873                 :   121407668 : }
     874                 :             : 
     875                 :             : /* Remove the contents of INSN_INFO (but don't free INSN_INFO itself).  */
     876                 :             : 
     877                 :             : static void
     878                 :   121275242 : df_insn_info_free_fields (df_insn_info *insn_info)
     879                 :             : {
     880                 :             :   /* In general, notes do not have the insn_info fields
     881                 :             :      initialized.  However, combine deletes insns by changing them
     882                 :             :      to notes.  How clever.  So we cannot just check if it is a
     883                 :             :      valid insn before short circuiting this code, we need to see
     884                 :             :      if we actually initialized it.  */
     885                 :   121275242 :   df_mw_hardreg_chain_delete (insn_info->mw_hardregs);
     886                 :             : 
     887                 :   121275242 :   if (df_chain)
     888                 :             :     {
     889                 :      705233 :       df_ref_chain_delete_du_chain (insn_info->defs);
     890                 :      705233 :       df_ref_chain_delete_du_chain (insn_info->uses);
     891                 :      705233 :       df_ref_chain_delete_du_chain (insn_info->eq_uses);
     892                 :             :     }
     893                 :             : 
     894                 :   121275242 :   df_ref_chain_delete (insn_info->defs);
     895                 :   121275242 :   df_ref_chain_delete (insn_info->uses);
     896                 :   121275242 :   df_ref_chain_delete (insn_info->eq_uses);
     897                 :   121275242 : }
     898                 :             : 
     899                 :             : /* Delete all of the refs information from the insn with UID.
     900                 :             :    Internal helper for df_insn_delete, df_insn_rescan, and other
     901                 :             :    df-scan routines that don't have to work in deferred mode
     902                 :             :    and do not have to mark basic blocks for re-processing.  */
     903                 :             : 
     904                 :             : static void
     905                 :    85872626 : df_insn_info_delete (unsigned int uid)
     906                 :             : {
     907                 :    85872626 :   struct df_insn_info *insn_info = DF_INSN_UID_SAFE_GET (uid);
     908                 :             : 
     909                 :    85872626 :   bitmap_clear_bit (&df->insns_to_delete, uid);
     910                 :    85872626 :   bitmap_clear_bit (&df->insns_to_rescan, uid);
     911                 :    85872626 :   bitmap_clear_bit (&df->insns_to_notes_rescan, uid);
     912                 :    85872626 :   if (insn_info)
     913                 :             :     {
     914                 :    76825470 :       struct df_scan_problem_data *problem_data
     915                 :    76825470 :         = (struct df_scan_problem_data *) df_scan->problem_data;
     916                 :             : 
     917                 :    76825470 :       df_insn_info_free_fields (insn_info);
     918                 :    76825470 :       problem_data->insn_pool->remove (insn_info);
     919                 :    76825470 :       DF_INSN_UID_SET (uid, NULL);
     920                 :             :     }
     921                 :    85872626 : }
     922                 :             : 
     923                 :             : /* Delete all of the refs information from INSN, either right now
     924                 :             :    or marked for later in deferred mode.  */
     925                 :             : 
     926                 :             : void
     927                 :    92257080 : df_insn_delete (rtx_insn *insn)
     928                 :             : {
     929                 :    92257080 :   unsigned int uid;
     930                 :    92257080 :   basic_block bb;
     931                 :             : 
     932                 :    92257080 :   gcc_checking_assert (INSN_P (insn));
     933                 :             : 
     934                 :    92257080 :   if (!df)
     935                 :             :     return;
     936                 :             : 
     937                 :    85875234 :   uid = INSN_UID (insn);
     938                 :    85875234 :   bb = BLOCK_FOR_INSN (insn);
     939                 :             : 
     940                 :             :   /* ??? bb can be NULL after pass_free_cfg.  At that point, DF should
     941                 :             :      not exist anymore (as mentioned in df-core.cc: "The only requirement
     942                 :             :      [for DF] is that there be a correct control flow graph."  Clearly
     943                 :             :      that isn't the case after pass_free_cfg.  But DF is freed much later
     944                 :             :      because some back-ends want to use DF info even though the CFG is
     945                 :             :      already gone.  It's not clear to me whether that is safe, actually.
     946                 :             :      In any case, we expect BB to be non-NULL at least up to register
     947                 :             :      allocation, so disallow a non-NULL BB up to there.  Not perfect
     948                 :             :      but better than nothing...  */
     949                 :    85875234 :   gcc_checking_assert (bb != NULL || reload_completed);
     950                 :             : 
     951                 :    85875234 :   df_grow_bb_info (df_scan);
     952                 :    85875234 :   df_grow_reg_info ();
     953                 :             : 
     954                 :             :   /* The block must be marked as dirty now, rather than later as in
     955                 :             :      df_insn_rescan and df_notes_rescan because it may not be there at
     956                 :             :      rescanning time and the mark would blow up.
     957                 :             :      DEBUG_INSNs do not make a block's data flow solution dirty (at
     958                 :             :      worst the LUIDs are no longer contiguous).  */
     959                 :    85875234 :   if (bb != NULL && NONDEBUG_INSN_P (insn))
     960                 :    46752951 :     df_set_bb_dirty (bb);
     961                 :             : 
     962                 :             :   /* The client has deferred rescanning.  */
     963                 :    85875234 :   if (df->changeable_flags & DF_DEFER_INSN_RESCAN)
     964                 :             :     {
     965                 :     4841246 :       struct df_insn_info *insn_info = DF_INSN_UID_SAFE_GET (uid);
     966                 :     4841246 :       if (insn_info)
     967                 :             :         {
     968                 :     4841246 :           bitmap_clear_bit (&df->insns_to_rescan, uid);
     969                 :     4841246 :           bitmap_clear_bit (&df->insns_to_notes_rescan, uid);
     970                 :     4841246 :           bitmap_set_bit (&df->insns_to_delete, uid);
     971                 :             :         }
     972                 :     4841246 :       if (dump_file)
     973                 :         707 :         fprintf (dump_file, "deferring deletion of insn with uid = %d.\n", uid);
     974                 :     4841246 :       return;
     975                 :             :     }
     976                 :             : 
     977                 :    81033988 :   if (dump_file)
     978                 :        1047 :     fprintf (dump_file, "deleting insn with uid = %d.\n", uid);
     979                 :             : 
     980                 :    81033988 :   df_insn_info_delete (uid);
     981                 :             : }
     982                 :             : 
     983                 :             : 
     984                 :             : /* Free all of the refs and the mw_hardregs in COLLECTION_REC.  */
     985                 :             : 
     986                 :             : static void
     987                 :   726290100 : df_free_collection_rec (class df_collection_rec *collection_rec)
     988                 :             : {
     989                 :   726290100 :   unsigned int ix;
     990                 :   726290100 :   struct df_scan_problem_data *problem_data
     991                 :   726290100 :     = (struct df_scan_problem_data *) df_scan->problem_data;
     992                 :   726290100 :   df_ref ref;
     993                 :   726290100 :   struct df_mw_hardreg *mw;
     994                 :             : 
     995                 :  5285303284 :   FOR_EACH_VEC_ELT (collection_rec->def_vec, ix, ref)
     996                 :  4559013184 :     df_free_ref (ref);
     997                 :  1499810163 :   FOR_EACH_VEC_ELT (collection_rec->use_vec, ix, ref)
     998                 :   773520063 :     df_free_ref (ref);
     999                 :   744574152 :   FOR_EACH_VEC_ELT (collection_rec->eq_use_vec, ix, ref)
    1000                 :    18284052 :     df_free_ref (ref);
    1001                 :   731003799 :   FOR_EACH_VEC_ELT (collection_rec->mw_vec, ix, mw)
    1002                 :     4713699 :     problem_data->mw_reg_pool->remove (mw);
    1003                 :             : 
    1004                 :   726290100 :   collection_rec->def_vec.release ();
    1005                 :   726290100 :   collection_rec->use_vec.release ();
    1006                 :   726290100 :   collection_rec->eq_use_vec.release ();
    1007                 :   726290100 :   collection_rec->mw_vec.release ();
    1008                 :   726290100 : }
    1009                 :             : 
    1010                 :             : /* Rescan INSN.  Return TRUE if the rescanning produced any changes.  */
    1011                 :             : 
    1012                 :             : bool
    1013                 :   208226479 : df_insn_rescan (rtx_insn *insn)
    1014                 :             : {
    1015                 :   208226479 :   unsigned int uid = INSN_UID (insn);
    1016                 :   208226479 :   struct df_insn_info *insn_info = NULL;
    1017                 :   208226479 :   basic_block bb = BLOCK_FOR_INSN (insn);
    1018                 :   208226479 :   class df_collection_rec collection_rec;
    1019                 :             : 
    1020                 :   208226479 :   if ((!df) || (!INSN_P (insn)))
    1021                 :             :     return false;
    1022                 :             : 
    1023                 :   180544517 :   if (!bb)
    1024                 :             :     {
    1025                 :          90 :       if (dump_file)
    1026                 :           0 :         fprintf (dump_file, "no bb for insn with uid = %d.\n", uid);
    1027                 :          90 :       return false;
    1028                 :             :     }
    1029                 :             : 
    1030                 :             :   /* The client has disabled rescanning and plans to do it itself.  */
    1031                 :   180544427 :   if (df->changeable_flags & DF_NO_INSN_RESCAN)
    1032                 :             :     return false;
    1033                 :             : 
    1034                 :   169377030 :   df_grow_bb_info (df_scan);
    1035                 :   169377030 :   df_grow_reg_info ();
    1036                 :             : 
    1037                 :   169377030 :   insn_info = DF_INSN_UID_SAFE_GET (uid);
    1038                 :             : 
    1039                 :             :   /* The client has deferred rescanning.  */
    1040                 :   169377030 :   if (df->changeable_flags & DF_DEFER_INSN_RESCAN)
    1041                 :             :     {
    1042                 :    33093392 :       if (!insn_info)
    1043                 :             :         {
    1044                 :     2811026 :           insn_info = df_insn_create_insn_record (insn);
    1045                 :     2811026 :           insn_info->defs = 0;
    1046                 :     2811026 :           insn_info->uses = 0;
    1047                 :     2811026 :           insn_info->eq_uses = 0;
    1048                 :     2811026 :           insn_info->mw_hardregs = 0;
    1049                 :             :         }
    1050                 :    33093392 :       if (dump_file)
    1051                 :        6654 :         fprintf (dump_file, "deferring rescan insn with uid = %d.\n", uid);
    1052                 :             : 
    1053                 :    33093392 :       bitmap_clear_bit (&df->insns_to_delete, uid);
    1054                 :    33093392 :       bitmap_clear_bit (&df->insns_to_notes_rescan, uid);
    1055                 :    33093392 :       bitmap_set_bit (&df->insns_to_rescan, INSN_UID (insn));
    1056                 :    33093392 :       return false;
    1057                 :             :     }
    1058                 :             : 
    1059                 :   136283638 :   bitmap_clear_bit (&df->insns_to_delete, uid);
    1060                 :   136283638 :   bitmap_clear_bit (&df->insns_to_rescan, uid);
    1061                 :   136283638 :   bitmap_clear_bit (&df->insns_to_notes_rescan, uid);
    1062                 :   136283638 :   if (insn_info)
    1063                 :             :     {
    1064                 :   101665907 :       int luid;
    1065                 :   101665907 :       bool the_same = df_insn_refs_verify (&collection_rec, bb, insn, false);
    1066                 :             :       /* If there's no change, return false. */
    1067                 :   101665907 :       if (the_same)
    1068                 :             :         {
    1069                 :    57216135 :           df_free_collection_rec (&collection_rec);
    1070                 :    57216135 :           if (dump_file)
    1071                 :        2865 :             fprintf (dump_file, "verify found no changes in insn with uid = %d.\n", uid);
    1072                 :    57216135 :           return false;
    1073                 :             :         }
    1074                 :    44449772 :       if (dump_file)
    1075                 :        5295 :         fprintf (dump_file, "rescanning insn with uid = %d.\n", uid);
    1076                 :             : 
    1077                 :             :       /* There's change - we need to delete the existing info.
    1078                 :             :          Since the insn isn't moved, we can salvage its LUID.  */
    1079                 :    44449772 :       luid = DF_INSN_LUID (insn);
    1080                 :    44449772 :       df_insn_info_free_fields (insn_info);
    1081                 :    44449772 :       df_insn_info_init_fields (insn_info, insn);
    1082                 :    44449772 :       DF_INSN_LUID (insn) = luid;
    1083                 :             :     }
    1084                 :             :   else
    1085                 :             :     {
    1086                 :    34617731 :       struct df_insn_info *insn_info = df_insn_create_insn_record (insn);
    1087                 :    34617731 :       df_insn_refs_collect (&collection_rec, bb, insn_info);
    1088                 :    34617731 :       if (dump_file)
    1089                 :        1049 :         fprintf (dump_file, "scanning new insn with uid = %d.\n", uid);
    1090                 :             :     }
    1091                 :             : 
    1092                 :    79067503 :   df_refs_add_to_chains (&collection_rec, bb, insn, copy_all);
    1093                 :    79067503 :   if (!DEBUG_INSN_P (insn))
    1094                 :    75438118 :     df_set_bb_dirty (bb);
    1095                 :             : 
    1096                 :             :   return true;
    1097                 :   208226479 : }
    1098                 :             : 
    1099                 :             : /* Same as df_insn_rescan, but don't mark the basic block as
    1100                 :             :    dirty.  */
    1101                 :             : 
    1102                 :             : bool
    1103                 :      132426 : df_insn_rescan_debug_internal (rtx_insn *insn)
    1104                 :             : {
    1105                 :      132426 :   unsigned int uid = INSN_UID (insn);
    1106                 :      132426 :   struct df_insn_info *insn_info;
    1107                 :             : 
    1108                 :      132426 :   gcc_assert (DEBUG_INSN_P (insn)
    1109                 :             :               && VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (insn)));
    1110                 :             : 
    1111                 :      132426 :   if (!df)
    1112                 :             :     return false;
    1113                 :             : 
    1114                 :      132426 :   insn_info = DF_INSN_UID_SAFE_GET (INSN_UID (insn));
    1115                 :      132426 :   if (!insn_info)
    1116                 :             :     return false;
    1117                 :             : 
    1118                 :      132426 :   if (dump_file)
    1119                 :           0 :     fprintf (dump_file, "deleting debug_insn with uid = %d.\n", uid);
    1120                 :             : 
    1121                 :      132426 :   bitmap_clear_bit (&df->insns_to_delete, uid);
    1122                 :      132426 :   bitmap_clear_bit (&df->insns_to_rescan, uid);
    1123                 :      132426 :   bitmap_clear_bit (&df->insns_to_notes_rescan, uid);
    1124                 :             : 
    1125                 :      132426 :   if (insn_info->defs == 0
    1126                 :      132426 :       && insn_info->uses == 0
    1127                 :           0 :       && insn_info->eq_uses == 0
    1128                 :           0 :       && insn_info->mw_hardregs == 0)
    1129                 :             :     return false;
    1130                 :             : 
    1131                 :      132426 :   df_mw_hardreg_chain_delete (insn_info->mw_hardregs);
    1132                 :             : 
    1133                 :      132426 :   if (df_chain)
    1134                 :             :     {
    1135                 :      119244 :       df_ref_chain_delete_du_chain (insn_info->defs);
    1136                 :      119244 :       df_ref_chain_delete_du_chain (insn_info->uses);
    1137                 :      119244 :       df_ref_chain_delete_du_chain (insn_info->eq_uses);
    1138                 :             :     }
    1139                 :             : 
    1140                 :      132426 :   df_ref_chain_delete (insn_info->defs);
    1141                 :      132426 :   df_ref_chain_delete (insn_info->uses);
    1142                 :      132426 :   df_ref_chain_delete (insn_info->eq_uses);
    1143                 :             : 
    1144                 :      132426 :   insn_info->defs = 0;
    1145                 :      132426 :   insn_info->uses = 0;
    1146                 :      132426 :   insn_info->eq_uses = 0;
    1147                 :      132426 :   insn_info->mw_hardregs = 0;
    1148                 :             : 
    1149                 :      132426 :   return true;
    1150                 :             : }
    1151                 :             : 
    1152                 :             : 
    1153                 :             : /* Rescan all of the insns in the function.  Note that the artificial
    1154                 :             :    uses and defs are not touched.  This function will destroy def-use
    1155                 :             :    or use-def chains.  */
    1156                 :             : 
    1157                 :             : void
    1158                 :       34246 : df_insn_rescan_all (void)
    1159                 :             : {
    1160                 :       34246 :   bool no_insn_rescan = false;
    1161                 :       34246 :   bool defer_insn_rescan = false;
    1162                 :       34246 :   basic_block bb;
    1163                 :       34246 :   bitmap_iterator bi;
    1164                 :       34246 :   unsigned int uid;
    1165                 :             : 
    1166                 :       34246 :   if (df->changeable_flags & DF_NO_INSN_RESCAN)
    1167                 :             :     {
    1168                 :           0 :       df_clear_flags (DF_NO_INSN_RESCAN);
    1169                 :           0 :       no_insn_rescan = true;
    1170                 :             :     }
    1171                 :             : 
    1172                 :       34246 :   if (df->changeable_flags & DF_DEFER_INSN_RESCAN)
    1173                 :             :     {
    1174                 :           0 :       df_clear_flags (DF_DEFER_INSN_RESCAN);
    1175                 :           0 :       defer_insn_rescan = true;
    1176                 :             :     }
    1177                 :             : 
    1178                 :       34246 :   auto_bitmap tmp (&df_bitmap_obstack);
    1179                 :       34246 :   bitmap_copy (tmp, &df->insns_to_delete);
    1180                 :       34246 :   EXECUTE_IF_SET_IN_BITMAP (tmp, 0, uid, bi)
    1181                 :             :     {
    1182                 :           0 :       struct df_insn_info *insn_info = DF_INSN_UID_SAFE_GET (uid);
    1183                 :           0 :       if (insn_info)
    1184                 :           0 :         df_insn_info_delete (uid);
    1185                 :             :     }
    1186                 :             : 
    1187                 :       34246 :   bitmap_clear (&df->insns_to_delete);
    1188                 :       34246 :   bitmap_clear (&df->insns_to_rescan);
    1189                 :       34246 :   bitmap_clear (&df->insns_to_notes_rescan);
    1190                 :             : 
    1191                 :     1140125 :   FOR_EACH_BB_FN (bb, cfun)
    1192                 :             :     {
    1193                 :     1105879 :       rtx_insn *insn;
    1194                 :    13067460 :       FOR_BB_INSNS (bb, insn)
    1195                 :             :         {
    1196                 :    11961581 :           df_insn_rescan (insn);
    1197                 :             :         }
    1198                 :             :     }
    1199                 :             : 
    1200                 :       34246 :   if (no_insn_rescan)
    1201                 :           0 :     df_set_flags (DF_NO_INSN_RESCAN);
    1202                 :       34246 :   if (defer_insn_rescan)
    1203                 :           0 :     df_set_flags (DF_DEFER_INSN_RESCAN);
    1204                 :       34246 : }
    1205                 :             : 
    1206                 :             : 
    1207                 :             : /* Process all of the deferred rescans or deletions.  */
    1208                 :             : 
    1209                 :             : void
    1210                 :    72521137 : df_process_deferred_rescans (void)
    1211                 :             : {
    1212                 :    72521137 :   bool no_insn_rescan = false;
    1213                 :    72521137 :   bool defer_insn_rescan = false;
    1214                 :    72521137 :   bitmap_iterator bi;
    1215                 :    72521137 :   unsigned int uid;
    1216                 :             : 
    1217                 :    72521137 :   if (df->changeable_flags & DF_NO_INSN_RESCAN)
    1218                 :             :     {
    1219                 :           0 :       df_clear_flags (DF_NO_INSN_RESCAN);
    1220                 :           0 :       no_insn_rescan = true;
    1221                 :             :     }
    1222                 :             : 
    1223                 :    72521137 :   if (df->changeable_flags & DF_DEFER_INSN_RESCAN)
    1224                 :             :     {
    1225                 :    10952112 :       df_clear_flags (DF_DEFER_INSN_RESCAN);
    1226                 :    10952112 :       defer_insn_rescan = true;
    1227                 :             :     }
    1228                 :             : 
    1229                 :    72521137 :   if (dump_file)
    1230                 :        3110 :     fprintf (dump_file, "starting the processing of deferred insns\n");
    1231                 :             : 
    1232                 :    72521137 :   auto_bitmap tmp (&df_bitmap_obstack);
    1233                 :    72521137 :   bitmap_copy (tmp, &df->insns_to_delete);
    1234                 :    77359775 :   EXECUTE_IF_SET_IN_BITMAP (tmp, 0, uid, bi)
    1235                 :             :     {
    1236                 :     9677276 :       struct df_insn_info *insn_info = DF_INSN_UID_SAFE_GET (uid);
    1237                 :     4838638 :       if (insn_info)
    1238                 :     4838638 :         df_insn_info_delete (uid);
    1239                 :             :     }
    1240                 :             : 
    1241                 :    72521137 :   bitmap_copy (tmp, &df->insns_to_rescan);
    1242                 :   101339458 :   EXECUTE_IF_SET_IN_BITMAP (tmp, 0, uid, bi)
    1243                 :             :     {
    1244                 :    57636642 :       struct df_insn_info *insn_info = DF_INSN_UID_SAFE_GET (uid);
    1245                 :    28818321 :       if (insn_info)
    1246                 :    28818321 :         df_insn_rescan (insn_info->insn);
    1247                 :             :     }
    1248                 :             : 
    1249                 :    72521137 :   bitmap_copy (tmp, &df->insns_to_notes_rescan);
    1250                 :    79277668 :   EXECUTE_IF_SET_IN_BITMAP (tmp, 0, uid, bi)
    1251                 :             :     {
    1252                 :    13513062 :       struct df_insn_info *insn_info = DF_INSN_UID_SAFE_GET (uid);
    1253                 :     6756531 :       if (insn_info)
    1254                 :     6756531 :         df_notes_rescan (insn_info->insn);
    1255                 :             :     }
    1256                 :             : 
    1257                 :    72521137 :   if (dump_file)
    1258                 :        3110 :     fprintf (dump_file, "ending the processing of deferred insns\n");
    1259                 :             : 
    1260                 :    72521137 :   bitmap_clear (&df->insns_to_delete);
    1261                 :    72521137 :   bitmap_clear (&df->insns_to_rescan);
    1262                 :    72521137 :   bitmap_clear (&df->insns_to_notes_rescan);
    1263                 :             : 
    1264                 :    72521137 :   if (no_insn_rescan)
    1265                 :           0 :     df_set_flags (DF_NO_INSN_RESCAN);
    1266                 :    72521137 :   if (defer_insn_rescan)
    1267                 :    10952112 :     df_set_flags (DF_DEFER_INSN_RESCAN);
    1268                 :             : 
    1269                 :             :   /* If someone changed regs_ever_live during this pass, fix up the
    1270                 :             :      entry and exit blocks.  */
    1271                 :    72521137 :   if (df->redo_entry_and_exit)
    1272                 :             :     {
    1273                 :      870596 :       df_update_entry_exit_and_calls ();
    1274                 :      870596 :       df->redo_entry_and_exit = false;
    1275                 :             :     }
    1276                 :    72521137 : }
    1277                 :             : 
    1278                 :             : 
    1279                 :             : /* Count the number of refs. Include the defs if INCLUDE_DEFS. Include
    1280                 :             :    the uses if INCLUDE_USES. Include the eq_uses if
    1281                 :             :    INCLUDE_EQ_USES.  */
    1282                 :             : 
    1283                 :             : static unsigned int
    1284                 :     5566829 : df_count_refs (bool include_defs, bool include_uses,
    1285                 :             :                bool include_eq_uses)
    1286                 :             : {
    1287                 :     5566829 :   unsigned int regno;
    1288                 :     5566829 :   int size = 0;
    1289                 :     5566829 :   unsigned int m = df->regs_inited;
    1290                 :             : 
    1291                 :  1288244688 :   for (regno = 0; regno < m; regno++)
    1292                 :             :     {
    1293                 :  1282677859 :       if (include_defs)
    1294                 :  1282677859 :         size += DF_REG_DEF_COUNT (regno);
    1295                 :  1282677859 :       if (include_uses)
    1296                 :           0 :         size += DF_REG_USE_COUNT (regno);
    1297                 :  1282677859 :       if (include_eq_uses)
    1298                 :           0 :         size += DF_REG_EQ_USE_COUNT (regno);
    1299                 :             :     }
    1300                 :     5566829 :   return size;
    1301                 :             : }
    1302                 :             : 
    1303                 :             : 
    1304                 :             : /* Take build ref table for either the uses or defs from the reg-use
    1305                 :             :    or reg-def chains.  This version processes the refs in reg order
    1306                 :             :    which is likely to be best if processing the whole function.  */
    1307                 :             : 
    1308                 :             : static void
    1309                 :     4456546 : df_reorganize_refs_by_reg_by_reg (struct df_ref_info *ref_info,
    1310                 :             :                                   bool include_defs,
    1311                 :             :                                   bool include_uses,
    1312                 :             :                                   bool include_eq_uses)
    1313                 :             : {
    1314                 :     4456546 :   unsigned int m = df->regs_inited;
    1315                 :     4456546 :   unsigned int regno;
    1316                 :     4456546 :   unsigned int offset = 0;
    1317                 :     4456546 :   unsigned int start;
    1318                 :             : 
    1319                 :     4456546 :   if (df->changeable_flags & DF_NO_HARD_REGS)
    1320                 :             :     {
    1321                 :       20531 :       start = FIRST_PSEUDO_REGISTER;
    1322                 :       20531 :       memset (ref_info->begin, 0, sizeof (int) * FIRST_PSEUDO_REGISTER);
    1323                 :       20531 :       memset (ref_info->count, 0, sizeof (int) * FIRST_PSEUDO_REGISTER);
    1324                 :             :     }
    1325                 :             :   else
    1326                 :             :     start = 0;
    1327                 :             : 
    1328                 :     4456546 :   ref_info->total_size
    1329                 :     4456546 :     = df_count_refs (include_defs, include_uses, include_eq_uses);
    1330                 :             : 
    1331                 :     4456546 :   df_check_and_grow_ref_info (ref_info, 1);
    1332                 :             : 
    1333                 :   632177147 :   for (regno = start; regno < m; regno++)
    1334                 :             :     {
    1335                 :   627720601 :       int count = 0;
    1336                 :   627720601 :       ref_info->begin[regno] = offset;
    1337                 :   627720601 :       if (include_defs)
    1338                 :             :         {
    1339                 :   627720601 :           df_ref ref = DF_REG_DEF_CHAIN (regno);
    1340                 :  2542069980 :           while (ref)
    1341                 :             :             {
    1342                 :  1914349379 :               ref_info->refs[offset] = ref;
    1343                 :  1914349379 :               DF_REF_ID (ref) = offset++;
    1344                 :  1914349379 :               count++;
    1345                 :  1914349379 :               ref = DF_REF_NEXT_REG (ref);
    1346                 :  1914349379 :               gcc_checking_assert (offset < ref_info->refs_size);
    1347                 :             :             }
    1348                 :             :         }
    1349                 :   627720601 :       if (include_uses)
    1350                 :             :         {
    1351                 :           0 :           df_ref ref = DF_REG_USE_CHAIN (regno);
    1352                 :           0 :           while (ref)
    1353                 :             :             {
    1354                 :           0 :               ref_info->refs[offset] = ref;
    1355                 :           0 :               DF_REF_ID (ref) = offset++;
    1356                 :           0 :               count++;
    1357                 :           0 :               ref = DF_REF_NEXT_REG (ref);
    1358                 :           0 :               gcc_checking_assert (offset < ref_info->refs_size);
    1359                 :             :             }
    1360                 :             :         }
    1361                 :   627720601 :       if (include_eq_uses)
    1362                 :             :         {
    1363                 :           0 :           df_ref ref = DF_REG_EQ_USE_CHAIN (regno);
    1364                 :           0 :           while (ref)
    1365                 :             :             {
    1366                 :           0 :               ref_info->refs[offset] = ref;
    1367                 :           0 :               DF_REF_ID (ref) = offset++;
    1368                 :           0 :               count++;
    1369                 :           0 :               ref = DF_REF_NEXT_REG (ref);
    1370                 :           0 :               gcc_checking_assert (offset < ref_info->refs_size);
    1371                 :             :             }
    1372                 :             :         }
    1373                 :   627720601 :       ref_info->count[regno] = count;
    1374                 :             :     }
    1375                 :             : 
    1376                 :             :   /* The bitmap size is not decremented when refs are deleted.  So
    1377                 :             :      reset it now that we have squished out all of the empty
    1378                 :             :      slots.  */
    1379                 :     4456546 :   ref_info->table_size = offset;
    1380                 :     4456546 : }
    1381                 :             : 
    1382                 :             : 
    1383                 :             : /* Take build ref table for either the uses or defs from the reg-use
    1384                 :             :    or reg-def chains.  This version processes the refs in insn order
    1385                 :             :    which is likely to be best if processing some segment of the
    1386                 :             :    function.  */
    1387                 :             : 
    1388                 :             : static void
    1389                 :     1110283 : df_reorganize_refs_by_reg_by_insn (struct df_ref_info *ref_info,
    1390                 :             :                                    bool include_defs,
    1391                 :             :                                    bool include_uses,
    1392                 :             :                                    bool include_eq_uses)
    1393                 :             : {
    1394                 :     1110283 :   bitmap_iterator bi;
    1395                 :     1110283 :   unsigned int bb_index;
    1396                 :     1110283 :   unsigned int m = df->regs_inited;
    1397                 :     1110283 :   unsigned int offset = 0;
    1398                 :     1110283 :   unsigned int r;
    1399                 :     2220566 :   unsigned int start
    1400                 :     1110283 :     = (df->changeable_flags & DF_NO_HARD_REGS) ? FIRST_PSEUDO_REGISTER : 0;
    1401                 :             : 
    1402                 :     1110283 :   memset (ref_info->begin, 0, sizeof (int) * df->regs_inited);
    1403                 :     1110283 :   memset (ref_info->count, 0, sizeof (int) * df->regs_inited);
    1404                 :             : 
    1405                 :     1110283 :   ref_info->total_size = df_count_refs (include_defs, include_uses, include_eq_uses);
    1406                 :     1110283 :   df_check_and_grow_ref_info (ref_info, 1);
    1407                 :             : 
    1408                 :     7950209 :   EXECUTE_IF_SET_IN_BITMAP (df->blocks_to_analyze, 0, bb_index, bi)
    1409                 :             :     {
    1410                 :     6839926 :       basic_block bb = BASIC_BLOCK_FOR_FN (cfun, bb_index);
    1411                 :     6839926 :       rtx_insn *insn;
    1412                 :     6839926 :       df_ref def, use;
    1413                 :             : 
    1414                 :     6839926 :       if (include_defs)
    1415                 :    13751395 :         FOR_EACH_ARTIFICIAL_DEF (def, bb_index)
    1416                 :             :           {
    1417                 :       71543 :             unsigned int regno = DF_REF_REGNO (def);
    1418                 :       71543 :             ref_info->count[regno]++;
    1419                 :             :           }
    1420                 :     6839926 :       if (include_uses)
    1421                 :           0 :         FOR_EACH_ARTIFICIAL_USE (use, bb_index)
    1422                 :             :           {
    1423                 :           0 :             unsigned int regno = DF_REF_REGNO (use);
    1424                 :           0 :             ref_info->count[regno]++;
    1425                 :             :           }
    1426                 :             : 
    1427                 :    75892241 :       FOR_BB_INSNS (bb, insn)
    1428                 :             :         {
    1429                 :    69052315 :           if (INSN_P (insn))
    1430                 :             :             {
    1431                 :    57570470 :               struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
    1432                 :             : 
    1433                 :    57570470 :               if (include_defs)
    1434                 :   204643706 :                 FOR_EACH_INSN_INFO_DEF (def, insn_info)
    1435                 :             :                   {
    1436                 :   147073236 :                     unsigned int regno = DF_REF_REGNO (def);
    1437                 :   147073236 :                     ref_info->count[regno]++;
    1438                 :             :                   }
    1439                 :    57570470 :               if (include_uses)
    1440                 :           0 :                 FOR_EACH_INSN_INFO_USE (use, insn_info)
    1441                 :             :                   {
    1442                 :           0 :                     unsigned int regno = DF_REF_REGNO (use);
    1443                 :           0 :                     ref_info->count[regno]++;
    1444                 :             :                   }
    1445                 :    57570470 :               if (include_eq_uses)
    1446                 :           0 :                 FOR_EACH_INSN_INFO_EQ_USE (use, insn_info)
    1447                 :             :                   {
    1448                 :           0 :                     unsigned int regno = DF_REF_REGNO (use);
    1449                 :           0 :                     ref_info->count[regno]++;
    1450                 :             :                   }
    1451                 :             :             }
    1452                 :             :         }
    1453                 :             :     }
    1454                 :             : 
    1455                 :   654178689 :   for (r = start; r < m; r++)
    1456                 :             :     {
    1457                 :   653068406 :       ref_info->begin[r] = offset;
    1458                 :   653068406 :       offset += ref_info->count[r];
    1459                 :   653068406 :       ref_info->count[r] = 0;
    1460                 :             :     }
    1461                 :             : 
    1462                 :     7950209 :   EXECUTE_IF_SET_IN_BITMAP (df->blocks_to_analyze, 0, bb_index, bi)
    1463                 :             :     {
    1464                 :     6839926 :       basic_block bb = BASIC_BLOCK_FOR_FN (cfun, bb_index);
    1465                 :     6839926 :       rtx_insn *insn;
    1466                 :     6839926 :       df_ref def, use;
    1467                 :             : 
    1468                 :     6839926 :       if (include_defs)
    1469                 :    13751395 :         FOR_EACH_ARTIFICIAL_DEF (def, bb_index)
    1470                 :             :           {
    1471                 :       71543 :             unsigned int regno = DF_REF_REGNO (def);
    1472                 :       71543 :             if (regno >= start)
    1473                 :             :               {
    1474                 :       71543 :                 unsigned int id
    1475                 :       71543 :                   = ref_info->begin[regno] + ref_info->count[regno]++;
    1476                 :       71543 :                 DF_REF_ID (def) = id;
    1477                 :       71543 :                 ref_info->refs[id] = def;
    1478                 :             :               }
    1479                 :             :           }
    1480                 :     6839926 :       if (include_uses)
    1481                 :           0 :         FOR_EACH_ARTIFICIAL_USE (use, bb_index)
    1482                 :             :           {
    1483                 :           0 :             unsigned int regno = DF_REF_REGNO (def);
    1484                 :           0 :             if (regno >= start)
    1485                 :             :               {
    1486                 :           0 :                 unsigned int id
    1487                 :           0 :                   = ref_info->begin[regno] + ref_info->count[regno]++;
    1488                 :           0 :                 DF_REF_ID (use) = id;
    1489                 :           0 :                 ref_info->refs[id] = use;
    1490                 :             :               }
    1491                 :             :           }
    1492                 :             : 
    1493                 :    75892241 :       FOR_BB_INSNS (bb, insn)
    1494                 :             :         {
    1495                 :    69052315 :           if (INSN_P (insn))
    1496                 :             :             {
    1497                 :    57570470 :               struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
    1498                 :             : 
    1499                 :    57570470 :               if (include_defs)
    1500                 :   204643706 :                 FOR_EACH_INSN_INFO_DEF (def, insn_info)
    1501                 :             :                   {
    1502                 :   147073236 :                     unsigned int regno = DF_REF_REGNO (def);
    1503                 :   147073236 :                     if (regno >= start)
    1504                 :             :                       {
    1505                 :   147073236 :                         unsigned int id
    1506                 :   147073236 :                           = ref_info->begin[regno] + ref_info->count[regno]++;
    1507                 :   147073236 :                         DF_REF_ID (def) = id;
    1508                 :   147073236 :                         ref_info->refs[id] = def;
    1509                 :             :                       }
    1510                 :             :                   }
    1511                 :    57570470 :               if (include_uses)
    1512                 :           0 :                 FOR_EACH_INSN_INFO_USE (use, insn_info)
    1513                 :             :                   {
    1514                 :           0 :                     unsigned int regno = DF_REF_REGNO (use);
    1515                 :           0 :                     if (regno >= start)
    1516                 :             :                       {
    1517                 :           0 :                         unsigned int id
    1518                 :           0 :                           = ref_info->begin[regno] + ref_info->count[regno]++;
    1519                 :           0 :                         DF_REF_ID (use) = id;
    1520                 :           0 :                         ref_info->refs[id] = use;
    1521                 :             :                       }
    1522                 :             :                   }
    1523                 :    57570470 :               if (include_eq_uses)
    1524                 :           0 :                 FOR_EACH_INSN_INFO_EQ_USE (use, insn_info)
    1525                 :             :                   {
    1526                 :           0 :                     unsigned int regno = DF_REF_REGNO (use);
    1527                 :           0 :                     if (regno >= start)
    1528                 :             :                       {
    1529                 :           0 :                         unsigned int id
    1530                 :           0 :                           = ref_info->begin[regno] + ref_info->count[regno]++;
    1531                 :           0 :                         DF_REF_ID (use) = id;
    1532                 :           0 :                         ref_info->refs[id] = use;
    1533                 :             :                       }
    1534                 :             :                   }
    1535                 :             :             }
    1536                 :             :         }
    1537                 :             :     }
    1538                 :             : 
    1539                 :             :   /* The bitmap size is not decremented when refs are deleted.  So
    1540                 :             :      reset it now that we have squished out all of the empty
    1541                 :             :      slots.  */
    1542                 :             : 
    1543                 :     1110283 :   ref_info->table_size = offset;
    1544                 :     1110283 : }
    1545                 :             : 
    1546                 :             : /* Take build ref table for either the uses or defs from the reg-use
    1547                 :             :    or reg-def chains.  */
    1548                 :             : 
    1549                 :             : static void
    1550                 :     5566829 : df_reorganize_refs_by_reg (struct df_ref_info *ref_info,
    1551                 :             :                            bool include_defs,
    1552                 :             :                            bool include_uses,
    1553                 :             :                            bool include_eq_uses)
    1554                 :             : {
    1555                 :     5566829 :   if (df->analyze_subset)
    1556                 :     1110283 :     df_reorganize_refs_by_reg_by_insn (ref_info, include_defs,
    1557                 :             :                                        include_uses, include_eq_uses);
    1558                 :             :   else
    1559                 :     4456546 :     df_reorganize_refs_by_reg_by_reg (ref_info, include_defs,
    1560                 :             :                                        include_uses, include_eq_uses);
    1561                 :     5566829 : }
    1562                 :             : 
    1563                 :             : 
    1564                 :             : /* Add the refs in REF_VEC to the table in REF_INFO starting at OFFSET.  */
    1565                 :             : static unsigned int
    1566                 :           0 : df_add_refs_to_table (unsigned int offset,
    1567                 :             :                       struct df_ref_info *ref_info,
    1568                 :             :                       df_ref ref)
    1569                 :             : {
    1570                 :           0 :   for (; ref; ref = DF_REF_NEXT_LOC (ref))
    1571                 :           0 :     if (!(df->changeable_flags & DF_NO_HARD_REGS)
    1572                 :           0 :         || (DF_REF_REGNO (ref) >= FIRST_PSEUDO_REGISTER))
    1573                 :             :       {
    1574                 :           0 :         ref_info->refs[offset] = ref;
    1575                 :           0 :         DF_REF_ID (ref) = offset++;
    1576                 :             :       }
    1577                 :           0 :   return offset;
    1578                 :             : }
    1579                 :             : 
    1580                 :             : 
    1581                 :             : /* Count the number of refs in all of the insns of BB. Include the
    1582                 :             :    defs if INCLUDE_DEFS. Include the uses if INCLUDE_USES. Include the
    1583                 :             :    eq_uses if INCLUDE_EQ_USES.  */
    1584                 :             : 
    1585                 :             : static unsigned int
    1586                 :           0 : df_reorganize_refs_by_insn_bb (basic_block bb, unsigned int offset,
    1587                 :             :                                struct df_ref_info *ref_info,
    1588                 :             :                                bool include_defs, bool include_uses,
    1589                 :             :                                bool include_eq_uses)
    1590                 :             : {
    1591                 :           0 :   rtx_insn *insn;
    1592                 :             : 
    1593                 :           0 :   if (include_defs)
    1594                 :           0 :     offset = df_add_refs_to_table (offset, ref_info,
    1595                 :           0 :                                    df_get_artificial_defs (bb->index));
    1596                 :           0 :   if (include_uses)
    1597                 :           0 :     offset = df_add_refs_to_table (offset, ref_info,
    1598                 :           0 :                                    df_get_artificial_uses (bb->index));
    1599                 :             : 
    1600                 :           0 :   FOR_BB_INSNS (bb, insn)
    1601                 :           0 :     if (INSN_P (insn))
    1602                 :             :       {
    1603                 :           0 :         unsigned int uid = INSN_UID (insn);
    1604                 :           0 :         if (include_defs)
    1605                 :           0 :           offset = df_add_refs_to_table (offset, ref_info,
    1606                 :           0 :                                          DF_INSN_UID_DEFS (uid));
    1607                 :           0 :         if (include_uses)
    1608                 :           0 :           offset = df_add_refs_to_table (offset, ref_info,
    1609                 :           0 :                                          DF_INSN_UID_USES (uid));
    1610                 :           0 :         if (include_eq_uses)
    1611                 :           0 :           offset = df_add_refs_to_table (offset, ref_info,
    1612                 :           0 :                                          DF_INSN_UID_EQ_USES (uid));
    1613                 :             :       }
    1614                 :           0 :   return offset;
    1615                 :             : }
    1616                 :             : 
    1617                 :             : 
    1618                 :             : /* Organize the refs by insn into the table in REF_INFO.  If
    1619                 :             :    blocks_to_analyze is defined, use that set, otherwise the entire
    1620                 :             :    program.  Include the defs if INCLUDE_DEFS. Include the uses if
    1621                 :             :    INCLUDE_USES. Include the eq_uses if INCLUDE_EQ_USES.  */
    1622                 :             : 
    1623                 :             : static void
    1624                 :           0 : df_reorganize_refs_by_insn (struct df_ref_info *ref_info,
    1625                 :             :                             bool include_defs, bool include_uses,
    1626                 :             :                             bool include_eq_uses)
    1627                 :             : {
    1628                 :           0 :   basic_block bb;
    1629                 :           0 :   unsigned int offset = 0;
    1630                 :             : 
    1631                 :           0 :   ref_info->total_size = df_count_refs (include_defs, include_uses, include_eq_uses);
    1632                 :           0 :   df_check_and_grow_ref_info (ref_info, 1);
    1633                 :           0 :   if (df->blocks_to_analyze)
    1634                 :             :     {
    1635                 :           0 :       bitmap_iterator bi;
    1636                 :           0 :       unsigned int index;
    1637                 :             : 
    1638                 :           0 :       EXECUTE_IF_SET_IN_BITMAP (df->blocks_to_analyze, 0, index, bi)
    1639                 :             :         {
    1640                 :           0 :           offset = df_reorganize_refs_by_insn_bb (BASIC_BLOCK_FOR_FN (cfun,
    1641                 :             :                                                                       index),
    1642                 :             :                                                   offset, ref_info,
    1643                 :             :                                                   include_defs, include_uses,
    1644                 :             :                                                   include_eq_uses);
    1645                 :             :         }
    1646                 :             : 
    1647                 :           0 :       ref_info->table_size = offset;
    1648                 :             :     }
    1649                 :             :   else
    1650                 :             :     {
    1651                 :           0 :       FOR_ALL_BB_FN (bb, cfun)
    1652                 :           0 :         offset = df_reorganize_refs_by_insn_bb (bb, offset, ref_info,
    1653                 :             :                                                 include_defs, include_uses,
    1654                 :             :                                                 include_eq_uses);
    1655                 :           0 :       ref_info->table_size = offset;
    1656                 :             :     }
    1657                 :           0 : }
    1658                 :             : 
    1659                 :             : 
    1660                 :             : /* If the use refs in DF are not organized, reorganize them.  */
    1661                 :             : 
    1662                 :             : void
    1663                 :    35355151 : df_maybe_reorganize_use_refs (enum df_ref_order order)
    1664                 :             : {
    1665                 :    35355151 :   if (order == df->use_info.ref_order)
    1666                 :             :     return;
    1667                 :             : 
    1668                 :           0 :   switch (order)
    1669                 :             :     {
    1670                 :           0 :     case DF_REF_ORDER_BY_REG:
    1671                 :           0 :       df_reorganize_refs_by_reg (&df->use_info, false, true, false);
    1672                 :           0 :       break;
    1673                 :             : 
    1674                 :           0 :     case DF_REF_ORDER_BY_REG_WITH_NOTES:
    1675                 :           0 :       df_reorganize_refs_by_reg (&df->use_info, false, true, true);
    1676                 :           0 :       break;
    1677                 :             : 
    1678                 :           0 :     case DF_REF_ORDER_BY_INSN:
    1679                 :           0 :       df_reorganize_refs_by_insn (&df->use_info, false, true, false);
    1680                 :           0 :       break;
    1681                 :             : 
    1682                 :           0 :     case DF_REF_ORDER_BY_INSN_WITH_NOTES:
    1683                 :           0 :       df_reorganize_refs_by_insn (&df->use_info, false, true, true);
    1684                 :           0 :       break;
    1685                 :             : 
    1686                 :           0 :     case DF_REF_ORDER_NO_TABLE:
    1687                 :           0 :       free (df->use_info.refs);
    1688                 :           0 :       df->use_info.refs = NULL;
    1689                 :           0 :       df->use_info.refs_size = 0;
    1690                 :           0 :       break;
    1691                 :             : 
    1692                 :           0 :     case DF_REF_ORDER_UNORDERED:
    1693                 :           0 :     case DF_REF_ORDER_UNORDERED_WITH_NOTES:
    1694                 :           0 :       gcc_unreachable ();
    1695                 :           0 :       break;
    1696                 :             :     }
    1697                 :             : 
    1698                 :           0 :   df->use_info.ref_order = order;
    1699                 :             : }
    1700                 :             : 
    1701                 :             : 
    1702                 :             : /* If the def refs in DF are not organized, reorganize them.  */
    1703                 :             : 
    1704                 :             : void
    1705                 :    40921980 : df_maybe_reorganize_def_refs (enum df_ref_order order)
    1706                 :             : {
    1707                 :    40921980 :   if (order == df->def_info.ref_order)
    1708                 :             :     return;
    1709                 :             : 
    1710                 :    11133658 :   switch (order)
    1711                 :             :     {
    1712                 :     5566829 :     case DF_REF_ORDER_BY_REG:
    1713                 :     5566829 :       df_reorganize_refs_by_reg (&df->def_info, true, false, false);
    1714                 :     5566829 :       break;
    1715                 :             : 
    1716                 :           0 :     case DF_REF_ORDER_BY_INSN:
    1717                 :           0 :       df_reorganize_refs_by_insn (&df->def_info, true, false, false);
    1718                 :           0 :       break;
    1719                 :             : 
    1720                 :     5566829 :     case DF_REF_ORDER_NO_TABLE:
    1721                 :     5566829 :       free (df->def_info.refs);
    1722                 :     5566829 :       df->def_info.refs = NULL;
    1723                 :     5566829 :       df->def_info.refs_size = 0;
    1724                 :     5566829 :       break;
    1725                 :             : 
    1726                 :           0 :     case DF_REF_ORDER_BY_INSN_WITH_NOTES:
    1727                 :           0 :     case DF_REF_ORDER_BY_REG_WITH_NOTES:
    1728                 :           0 :     case DF_REF_ORDER_UNORDERED:
    1729                 :           0 :     case DF_REF_ORDER_UNORDERED_WITH_NOTES:
    1730                 :           0 :       gcc_unreachable ();
    1731                 :    11133658 :       break;
    1732                 :             :     }
    1733                 :             : 
    1734                 :    11133658 :   df->def_info.ref_order = order;
    1735                 :             : }
    1736                 :             : 
    1737                 :             : 
    1738                 :             : /* Change all of the basic block references in INSN to use the insn's
    1739                 :             :    current basic block.  This function is called from routines that move
    1740                 :             :    instructions from one block to another.  */
    1741                 :             : 
    1742                 :             : void
    1743                 :   255817543 : df_insn_change_bb (rtx_insn *insn, basic_block new_bb)
    1744                 :             : {
    1745                 :   255817543 :   basic_block old_bb = BLOCK_FOR_INSN (insn);
    1746                 :   255817543 :   struct df_insn_info *insn_info;
    1747                 :   255817543 :   unsigned int uid = INSN_UID (insn);
    1748                 :             : 
    1749                 :   255817543 :   if (old_bb == new_bb)
    1750                 :             :     return;
    1751                 :             : 
    1752                 :   224813911 :   set_block_for_insn (insn, new_bb);
    1753                 :             : 
    1754                 :   224813911 :   if (!df)
    1755                 :             :     return;
    1756                 :             : 
    1757                 :    29123948 :   if (dump_file)
    1758                 :        6404 :     fprintf (dump_file, "changing bb of uid %d\n", uid);
    1759                 :             : 
    1760                 :    29123948 :   insn_info = DF_INSN_UID_SAFE_GET (uid);
    1761                 :    28983508 :   if (insn_info == NULL)
    1762                 :             :     {
    1763                 :    10450360 :       if (dump_file)
    1764                 :        6131 :         fprintf (dump_file, "  unscanned insn\n");
    1765                 :    10450360 :       df_insn_rescan (insn);
    1766                 :    10450360 :       return;
    1767                 :             :     }
    1768                 :             : 
    1769                 :    18673588 :   if (!INSN_P (insn))
    1770                 :             :     return;
    1771                 :             : 
    1772                 :    16682600 :   if (!DEBUG_INSN_P (insn))
    1773                 :    13496066 :     df_set_bb_dirty (new_bb);
    1774                 :    16682600 :   if (old_bb)
    1775                 :             :     {
    1776                 :    16677148 :       if (dump_file)
    1777                 :         242 :         fprintf (dump_file, "  from %d to %d\n",
    1778                 :             :                  old_bb->index, new_bb->index);
    1779                 :    16677148 :       if (!DEBUG_INSN_P (insn))
    1780                 :    13490661 :         df_set_bb_dirty (old_bb);
    1781                 :             :     }
    1782                 :             :   else
    1783                 :        5452 :     if (dump_file)
    1784                 :           0 :       fprintf (dump_file, "  to %d\n", new_bb->index);
    1785                 :             : }
    1786                 :             : 
    1787                 :             : 
    1788                 :             : /* Helper function for df_ref_change_reg_with_loc.  */
    1789                 :             : 
    1790                 :             : static void
    1791                 :   102201912 : df_ref_change_reg_with_loc_1 (struct df_reg_info *old_df,
    1792                 :             :                               struct df_reg_info *new_df,
    1793                 :             :                               unsigned int new_regno, rtx loc)
    1794                 :             : {
    1795                 :   102201912 :   df_ref the_ref = old_df->reg_chain;
    1796                 :             : 
    1797                 :   188698335 :   while (the_ref)
    1798                 :             :     {
    1799                 :    86496423 :       if ((!DF_REF_IS_ARTIFICIAL (the_ref))
    1800                 :    86496423 :           && DF_REF_LOC (the_ref)
    1801                 :    86496423 :           && (*DF_REF_LOC (the_ref) == loc))
    1802                 :             :         {
    1803                 :    80285461 :           df_ref next_ref = DF_REF_NEXT_REG (the_ref);
    1804                 :    80285461 :           df_ref prev_ref = DF_REF_PREV_REG (the_ref);
    1805                 :    80285461 :           df_ref *ref_ptr;
    1806                 :    80285461 :           struct df_insn_info *insn_info = DF_REF_INSN_INFO (the_ref);
    1807                 :             : 
    1808                 :    80285461 :           DF_REF_REGNO (the_ref) = new_regno;
    1809                 :    80285461 :           DF_REF_REG (the_ref) = regno_reg_rtx[new_regno];
    1810                 :             : 
    1811                 :             :           /* Pull the_ref out of the old regno chain.  */
    1812                 :    80285461 :           if (prev_ref)
    1813                 :     2214719 :             DF_REF_NEXT_REG (prev_ref) = next_ref;
    1814                 :             :           else
    1815                 :    78070742 :             old_df->reg_chain = next_ref;
    1816                 :    80285461 :           if (next_ref)
    1817                 :    25232719 :             DF_REF_PREV_REG (next_ref) = prev_ref;
    1818                 :    80285461 :           old_df->n_refs--;
    1819                 :             : 
    1820                 :             :           /* Put the ref into the new regno chain.  */
    1821                 :    80285461 :           DF_REF_PREV_REG (the_ref) = NULL;
    1822                 :    80285461 :           DF_REF_NEXT_REG (the_ref) = new_df->reg_chain;
    1823                 :    80285461 :           if (new_df->reg_chain)
    1824                 :    76445536 :             DF_REF_PREV_REG (new_df->reg_chain) = the_ref;
    1825                 :    80285461 :           new_df->reg_chain = the_ref;
    1826                 :    80285461 :           new_df->n_refs++;
    1827                 :    80285461 :           if (DF_REF_BB (the_ref))
    1828                 :    80285461 :             df_set_bb_dirty (DF_REF_BB (the_ref));
    1829                 :             : 
    1830                 :             :           /* Need to sort the record again that the ref was in because
    1831                 :             :              the regno is a sorting key.  First, find the right
    1832                 :             :              record.  */
    1833                 :    80285461 :           if (DF_REF_REG_DEF_P (the_ref))
    1834                 :    31604143 :             ref_ptr = &insn_info->defs;
    1835                 :    48681318 :           else if (DF_REF_FLAGS (the_ref) & DF_REF_IN_NOTE)
    1836                 :     1624968 :             ref_ptr = &insn_info->eq_uses;
    1837                 :             :           else
    1838                 :    47056350 :             ref_ptr = &insn_info->uses;
    1839                 :    80285461 :           if (dump_file)
    1840                 :        2507 :             fprintf (dump_file, "changing reg in insn %d\n",
    1841                 :        2507 :                      DF_REF_INSN_UID (the_ref));
    1842                 :             : 
    1843                 :             :           /* Stop if we find the current reference or where the reference
    1844                 :             :              needs to be.  */
    1845                 :    86740823 :           while (*ref_ptr != the_ref && df_ref_compare (*ref_ptr, the_ref) < 0)
    1846                 :     6455362 :             ref_ptr = &DF_REF_NEXT_LOC (*ref_ptr);
    1847                 :    80285461 :           if (*ref_ptr != the_ref)
    1848                 :             :             {
    1849                 :             :               /* The reference needs to be promoted up the list.  */
    1850                 :    14901808 :               df_ref next = DF_REF_NEXT_LOC (the_ref);
    1851                 :    14901808 :               DF_REF_NEXT_LOC (the_ref) = *ref_ptr;
    1852                 :    14901808 :               *ref_ptr = the_ref;
    1853                 :    31395778 :               do
    1854                 :    31395778 :                 ref_ptr = &DF_REF_NEXT_LOC (*ref_ptr);
    1855                 :    31395778 :               while (*ref_ptr != the_ref);
    1856                 :    14901808 :               *ref_ptr = next;
    1857                 :             :             }
    1858                 :    65383653 :           else if (DF_REF_NEXT_LOC (the_ref)
    1859                 :    65383653 :                    && df_ref_compare (the_ref, DF_REF_NEXT_LOC (the_ref)) > 0)
    1860                 :             :             {
    1861                 :             :               /* The reference needs to be demoted down the list.  */
    1862                 :           0 :               *ref_ptr = DF_REF_NEXT_LOC (the_ref);
    1863                 :           0 :               do
    1864                 :           0 :                 ref_ptr = &DF_REF_NEXT_LOC (*ref_ptr);
    1865                 :           0 :               while (*ref_ptr && df_ref_compare (the_ref, *ref_ptr) > 0);
    1866                 :           0 :               DF_REF_NEXT_LOC (the_ref) = *ref_ptr;
    1867                 :           0 :               *ref_ptr = the_ref;
    1868                 :             :             }
    1869                 :             : 
    1870                 :             :           the_ref = next_ref;
    1871                 :             :         }
    1872                 :             :       else
    1873                 :     6210962 :         the_ref = DF_REF_NEXT_REG (the_ref);
    1874                 :             :     }
    1875                 :   102201912 : }
    1876                 :             : 
    1877                 :             : 
    1878                 :             : /* Change the regno of register LOC to NEW_REGNO and update the df
    1879                 :             :    information accordingly.  Refs that do not match LOC are not changed
    1880                 :             :    which means that artificial refs are not changed since they have no loc.
    1881                 :             :    This call is to support the SET_REGNO macro. */
    1882                 :             : 
    1883                 :             : void
    1884                 :    34067304 : df_ref_change_reg_with_loc (rtx loc, unsigned int new_regno)
    1885                 :             : {
    1886                 :    34067304 :   unsigned int old_regno = REGNO (loc);
    1887                 :    34067304 :   if (old_regno == new_regno)
    1888                 :             :     return;
    1889                 :             : 
    1890                 :    34067304 :   if (df)
    1891                 :             :     {
    1892                 :    34067304 :       df_grow_reg_info ();
    1893                 :             : 
    1894                 :    34067304 :       df_ref_change_reg_with_loc_1 (DF_REG_DEF_GET (old_regno),
    1895                 :    34067304 :                                     DF_REG_DEF_GET (new_regno),
    1896                 :             :                                     new_regno, loc);
    1897                 :    34067304 :       df_ref_change_reg_with_loc_1 (DF_REG_USE_GET (old_regno),
    1898                 :    34067304 :                                     DF_REG_USE_GET (new_regno),
    1899                 :             :                                     new_regno, loc);
    1900                 :    34067304 :       df_ref_change_reg_with_loc_1 (DF_REG_EQ_USE_GET (old_regno),
    1901                 :    34067304 :                                     DF_REG_EQ_USE_GET (new_regno),
    1902                 :             :                                     new_regno, loc);
    1903                 :             :     }
    1904                 :    34067304 :   set_mode_and_regno (loc, GET_MODE (loc), new_regno);
    1905                 :             : }
    1906                 :             : 
    1907                 :             : 
    1908                 :             : /* Delete the mw_hardregs that point into the eq_notes.  */
    1909                 :             : 
    1910                 :             : static void
    1911                 :    22538851 : df_mw_hardreg_chain_delete_eq_uses (struct df_insn_info *insn_info)
    1912                 :             : {
    1913                 :    22538851 :   struct df_mw_hardreg **mw_ptr = &insn_info->mw_hardregs;
    1914                 :    22538851 :   struct df_scan_problem_data *problem_data
    1915                 :    22538851 :     = (struct df_scan_problem_data *) df_scan->problem_data;
    1916                 :             : 
    1917                 :    22558983 :   while (*mw_ptr)
    1918                 :             :     {
    1919                 :       20132 :       df_mw_hardreg *mw = *mw_ptr;
    1920                 :       20132 :       if (mw->flags & DF_REF_IN_NOTE)
    1921                 :             :         {
    1922                 :           1 :           *mw_ptr = DF_MWS_NEXT (mw);
    1923                 :           1 :           problem_data->mw_reg_pool->remove (mw);
    1924                 :             :         }
    1925                 :             :       else
    1926                 :       20131 :         mw_ptr = &DF_MWS_NEXT (mw);
    1927                 :             :     }
    1928                 :    22538851 : }
    1929                 :             : 
    1930                 :             : 
    1931                 :             : /* Rescan only the REG_EQUIV/REG_EQUAL notes part of INSN.  */
    1932                 :             : 
    1933                 :             : void
    1934                 :    48378765 : df_notes_rescan (rtx_insn *insn)
    1935                 :             : {
    1936                 :    48378765 :   struct df_insn_info *insn_info;
    1937                 :    48378765 :   unsigned int uid = INSN_UID (insn);
    1938                 :             : 
    1939                 :    48378765 :   if (!df)
    1940                 :             :     return;
    1941                 :             : 
    1942                 :             :   /* The client has disabled rescanning and plans to do it itself.  */
    1943                 :    44422906 :   if (df->changeable_flags & DF_NO_INSN_RESCAN)
    1944                 :             :     return;
    1945                 :             : 
    1946                 :             :   /* Do nothing if the insn hasn't been emitted yet.  */
    1947                 :    44406026 :   if (!BLOCK_FOR_INSN (insn))
    1948                 :             :     return;
    1949                 :             : 
    1950                 :    44390558 :   df_grow_bb_info (df_scan);
    1951                 :    44390558 :   df_grow_reg_info ();
    1952                 :             : 
    1953                 :    44390558 :   insn_info = DF_INSN_UID_SAFE_GET (INSN_UID (insn));
    1954                 :             : 
    1955                 :             :   /* The client has deferred rescanning.  */
    1956                 :    44390558 :   if (df->changeable_flags & DF_DEFER_INSN_RESCAN)
    1957                 :             :     {
    1958                 :    21851707 :       if (!insn_info)
    1959                 :             :         {
    1960                 :           0 :           insn_info = df_insn_create_insn_record (insn);
    1961                 :           0 :           insn_info->defs = 0;
    1962                 :           0 :           insn_info->uses = 0;
    1963                 :           0 :           insn_info->eq_uses = 0;
    1964                 :           0 :           insn_info->mw_hardregs = 0;
    1965                 :             :         }
    1966                 :             : 
    1967                 :    21851707 :       bitmap_clear_bit (&df->insns_to_delete, uid);
    1968                 :             :       /* If the insn is set to be rescanned, it does not need to also
    1969                 :             :          be notes rescanned.  */
    1970                 :    21851707 :       if (!bitmap_bit_p (&df->insns_to_rescan, uid))
    1971                 :    17584832 :         bitmap_set_bit (&df->insns_to_notes_rescan, INSN_UID (insn));
    1972                 :    21851707 :       return;
    1973                 :             :     }
    1974                 :             : 
    1975                 :    22538851 :   bitmap_clear_bit (&df->insns_to_delete, uid);
    1976                 :    22538851 :   bitmap_clear_bit (&df->insns_to_notes_rescan, uid);
    1977                 :             : 
    1978                 :    22538851 :   if (insn_info)
    1979                 :             :     {
    1980                 :    22538851 :       basic_block bb = BLOCK_FOR_INSN (insn);
    1981                 :    22538851 :       rtx note;
    1982                 :    22538851 :       class df_collection_rec collection_rec;
    1983                 :    22538851 :       unsigned int i;
    1984                 :             : 
    1985                 :    22538851 :       df_mw_hardreg_chain_delete_eq_uses (insn_info);
    1986                 :    22538851 :       df_ref_chain_delete (insn_info->eq_uses);
    1987                 :    22538851 :       insn_info->eq_uses = NULL;
    1988                 :             : 
    1989                 :             :       /* Process REG_EQUIV/REG_EQUAL notes */
    1990                 :    55728635 :       for (note = REG_NOTES (insn); note;
    1991                 :    33189784 :            note = XEXP (note, 1))
    1992                 :             :         {
    1993                 :    33189784 :           switch (REG_NOTE_KIND (note))
    1994                 :             :             {
    1995                 :    18004678 :             case REG_EQUIV:
    1996                 :    18004678 :             case REG_EQUAL:
    1997                 :    18004678 :               df_uses_record (&collection_rec,
    1998                 :             :                               &XEXP (note, 0), DF_REF_REG_USE,
    1999                 :             :                               bb, insn_info, DF_REF_IN_NOTE);
    2000                 :    33189784 :             default:
    2001                 :    33189784 :               break;
    2002                 :             :             }
    2003                 :             :         }
    2004                 :             : 
    2005                 :             :       /* Find some place to put any new mw_hardregs.  */
    2006                 :    22538851 :       df_canonize_collection_rec (&collection_rec);
    2007                 :    22538851 :       struct df_mw_hardreg **mw_ptr = &insn_info->mw_hardregs, *mw;
    2008                 :    22538851 :       FOR_EACH_VEC_ELT (collection_rec.mw_vec, i, mw)
    2009                 :             :         {
    2010                 :           0 :           while (*mw_ptr && df_mw_compare (*mw_ptr, mw) < 0)
    2011                 :           0 :             mw_ptr = &DF_MWS_NEXT (*mw_ptr);
    2012                 :           0 :           DF_MWS_NEXT (mw) = *mw_ptr;
    2013                 :           0 :           *mw_ptr = mw;
    2014                 :           0 :           mw_ptr = &DF_MWS_NEXT (mw);
    2015                 :             :         }
    2016                 :    22538851 :       df_refs_add_to_chains (&collection_rec, bb, insn, copy_eq_uses);
    2017                 :    22538851 :     }
    2018                 :             :   else
    2019                 :           0 :     df_insn_rescan (insn);
    2020                 :             : 
    2021                 :             : }
    2022                 :             : 
    2023                 :             : 
    2024                 :             : /*----------------------------------------------------------------------------
    2025                 :             :    Hard core instruction scanning code.  No external interfaces here,
    2026                 :             :    just a lot of routines that look inside insns.
    2027                 :             : ----------------------------------------------------------------------------*/
    2028                 :             : 
    2029                 :             : 
    2030                 :             : /* Return true if the contents of two df_ref's are identical.
    2031                 :             :    It ignores DF_REF_MARKER.  */
    2032                 :             : 
    2033                 :             : static bool
    2034                 :  5869194735 : df_ref_equal_p (df_ref ref1, df_ref ref2)
    2035                 :             : {
    2036                 :  5869194735 :   if (!ref2)
    2037                 :             :     return false;
    2038                 :             : 
    2039                 :  5869194735 :   if (ref1 == ref2)
    2040                 :             :     return true;
    2041                 :             : 
    2042                 :  5869194735 :   if (DF_REF_CLASS (ref1) != DF_REF_CLASS (ref2)
    2043                 :  5869194735 :       || DF_REF_REGNO (ref1) != DF_REF_REGNO (ref2)
    2044                 :  5425959601 :       || DF_REF_REG (ref1) != DF_REF_REG (ref2)
    2045                 :  5425561117 :       || DF_REF_TYPE (ref1) != DF_REF_TYPE (ref2)
    2046                 :  5422131000 :       || ((DF_REF_FLAGS (ref1) & ~(DF_REF_REG_MARKER + DF_REF_MW_HARDREG))
    2047                 :  5422131000 :           != (DF_REF_FLAGS (ref2) & ~(DF_REF_REG_MARKER + DF_REF_MW_HARDREG)))
    2048                 :  5420121265 :       || DF_REF_BB (ref1) != DF_REF_BB (ref2)
    2049                 : 11289316000 :       || DF_REF_INSN_INFO (ref1) != DF_REF_INSN_INFO (ref2))
    2050                 :             :     return false;
    2051                 :             : 
    2052                 :  5420121265 :   switch (DF_REF_CLASS (ref1))
    2053                 :             :     {
    2054                 :             :     case DF_REF_ARTIFICIAL:
    2055                 :             :     case DF_REF_BASE:
    2056                 :             :       return true;
    2057                 :             : 
    2058                 :   944063072 :     case DF_REF_REGULAR:
    2059                 :   944063072 :       return DF_REF_LOC (ref1) == DF_REF_LOC (ref2);
    2060                 :             : 
    2061                 :           0 :     default:
    2062                 :           0 :       gcc_unreachable ();
    2063                 :             :     }
    2064                 :             : }
    2065                 :             : 
    2066                 :             : 
    2067                 :             : /* Compare REF1 and REF2 for sorting.  This is only called from places
    2068                 :             :    where all of the refs are of the same type, in the same insn, and
    2069                 :             :    have the same bb.  So these fields are not checked.  */
    2070                 :             : 
    2071                 :             : static int
    2072                 :  8675288019 : df_ref_compare (df_ref ref1, df_ref ref2)
    2073                 :             : {
    2074                 :  8675288019 :   if (DF_REF_CLASS (ref1) != DF_REF_CLASS (ref2))
    2075                 :   560274106 :     return (int)DF_REF_CLASS (ref1) - (int)DF_REF_CLASS (ref2);
    2076                 :             : 
    2077                 :  8115013913 :   if (DF_REF_REGNO (ref1) != DF_REF_REGNO (ref2))
    2078                 :  8061484269 :     return (int)DF_REF_REGNO (ref1) - (int)DF_REF_REGNO (ref2);
    2079                 :             : 
    2080                 :    53529644 :   if (DF_REF_TYPE (ref1) != DF_REF_TYPE (ref2))
    2081                 :     7607361 :     return (int)DF_REF_TYPE (ref1) - (int)DF_REF_TYPE (ref2);
    2082                 :             : 
    2083                 :    45922283 :   if (DF_REF_REG (ref1) != DF_REF_REG (ref2))
    2084                 :      364938 :     return (int)DF_REF_ORDER (ref1) - (int)DF_REF_ORDER (ref2);
    2085                 :             : 
    2086                 :             :   /* Cannot look at the LOC field on artificial refs.  */
    2087                 :    45557345 :   if (DF_REF_CLASS (ref1) != DF_REF_ARTIFICIAL
    2088                 :    45557345 :       && DF_REF_LOC (ref1) != DF_REF_LOC (ref2))
    2089                 :    33206568 :     return (int)DF_REF_ORDER (ref1) - (int)DF_REF_ORDER (ref2);
    2090                 :             : 
    2091                 :    12350777 :   if (DF_REF_FLAGS (ref1) != DF_REF_FLAGS (ref2))
    2092                 :             :     {
    2093                 :             :       /* If two refs are identical except that one of them has is from
    2094                 :             :          a mw and one is not, we need to have the one with the mw
    2095                 :             :          first.  */
    2096                 :     9800179 :       if (DF_REF_FLAGS_IS_SET (ref1, DF_REF_MW_HARDREG) ==
    2097                 :     9800179 :           DF_REF_FLAGS_IS_SET (ref2, DF_REF_MW_HARDREG))
    2098                 :     9800179 :         return DF_REF_FLAGS (ref1) - DF_REF_FLAGS (ref2);
    2099                 :           0 :       else if (DF_REF_FLAGS_IS_SET (ref1, DF_REF_MW_HARDREG))
    2100                 :             :         return -1;
    2101                 :             :       else
    2102                 :           0 :         return 1;
    2103                 :             :     }
    2104                 :             : 
    2105                 :     2550598 :   return (int)DF_REF_ORDER (ref1) - (int)DF_REF_ORDER (ref2);
    2106                 :             : }
    2107                 :             : 
    2108                 :             : /* Like df_ref_compare, but compare two df_ref* pointers R1 and R2.  */
    2109                 :             : 
    2110                 :             : static int
    2111                 :  2861558410 : df_ref_ptr_compare (const void *r1, const void *r2)
    2112                 :             : {
    2113                 :  2861558410 :   return df_ref_compare (*(const df_ref *) r1, *(const df_ref *) r2);
    2114                 :             : }
    2115                 :             : 
    2116                 :             : /* Sort and compress a set of refs.  */
    2117                 :             : 
    2118                 :             : static void
    2119                 :  3380192646 : df_sort_and_compress_refs (vec<df_ref, va_heap> *ref_vec)
    2120                 :             : {
    2121                 :  3380192646 :   unsigned int count;
    2122                 :  3380192646 :   unsigned int i;
    2123                 :  3380192646 :   unsigned int dist = 0;
    2124                 :             : 
    2125                 :  3380192646 :   count = ref_vec->length ();
    2126                 :             : 
    2127                 :             :   /* If there are 1 or 0 elements, there is nothing to do.  */
    2128                 :  3380190818 :   if (count < 2)
    2129                 :             :     return;
    2130                 :   430306828 :   else if (count == 2)
    2131                 :             :     {
    2132                 :   256246038 :       df_ref r0 = (*ref_vec)[0];
    2133                 :   256246038 :       df_ref r1 = (*ref_vec)[1];
    2134                 :   256246038 :       if (df_ref_compare (r0, r1) > 0)
    2135                 :   106820939 :         std::swap ((*ref_vec)[0], (*ref_vec)[1]);
    2136                 :             :     }
    2137                 :             :   else
    2138                 :             :     {
    2139                 :  5663449578 :       for (i = 0; i < count - 1; i++)
    2140                 :             :         {
    2141                 :  5529408329 :           df_ref r0 = (*ref_vec)[i];
    2142                 :  5529408329 :           df_ref r1 = (*ref_vec)[i + 1];
    2143                 :  5529408329 :           if (df_ref_compare (r0, r1) >= 0)
    2144                 :             :             break;
    2145                 :             :         }
    2146                 :             :       /* If the array is already strictly ordered,
    2147                 :             :          which is the most common case for large COUNT case
    2148                 :             :          (which happens for CALL INSNs),
    2149                 :             :          no need to sort and filter out duplicate.
    2150                 :             :          Simply return the count.
    2151                 :             :          Make sure DF_GET_ADD_REFS adds refs in the increasing order
    2152                 :             :          of DF_REF_COMPARE.  */
    2153                 :   174060790 :       if (i == count - 1)
    2154                 :             :         return;
    2155                 :    40019541 :       ref_vec->qsort (df_ref_ptr_compare);
    2156                 :             :     }
    2157                 :             : 
    2158                 :  1025956495 :   for (i=0; i<count-dist; i++)
    2159                 :             :     {
    2160                 :             :       /* Find the next ref that is not equal to the current ref.  */
    2161                 :   730060463 :       while (i + dist + 1 < count
    2162                 :  1163855347 :              && df_ref_equal_p ((*ref_vec)[i],
    2163                 :   433794884 :                                 (*ref_vec)[i + dist + 1]))
    2164                 :             :         {
    2165                 :      369547 :           df_free_ref ((*ref_vec)[i + dist + 1]);
    2166                 :      369547 :           dist++;
    2167                 :             :         }
    2168                 :             :       /* Copy it down to the next position.  */
    2169                 :   729690916 :       if (dist && i + dist + 1 < count)
    2170                 :       82209 :         (*ref_vec)[i + 1] = (*ref_vec)[i + dist + 1];
    2171                 :             :     }
    2172                 :             : 
    2173                 :   296265579 :   count -= dist;
    2174                 :   296265579 :   ref_vec->truncate (count);
    2175                 :             : }
    2176                 :             : 
    2177                 :             : 
    2178                 :             : /* Return true if the contents of two df_ref's are identical.
    2179                 :             :    It ignores DF_REF_MARKER.  */
    2180                 :             : 
    2181                 :             : static bool
    2182                 :     5443544 : df_mw_equal_p (struct df_mw_hardreg *mw1, struct df_mw_hardreg *mw2)
    2183                 :             : {
    2184                 :     5443544 :   if (!mw2)
    2185                 :             :     return false;
    2186                 :     5443544 :   return (mw1 == mw2) ||
    2187                 :     5443544 :     (mw1->mw_reg == mw2->mw_reg
    2188                 :             :      && mw1->type == mw2->type
    2189                 :             :      && mw1->flags == mw2->flags
    2190                 :     4976825 :      && mw1->start_regno == mw2->start_regno
    2191                 :     4736779 :      && mw1->end_regno == mw2->end_regno);
    2192                 :             : }
    2193                 :             : 
    2194                 :             : 
    2195                 :             : /* Compare MW1 and MW2 for sorting.  */
    2196                 :             : 
    2197                 :             : static int
    2198                 :     1627255 : df_mw_compare (const df_mw_hardreg *mw1, const df_mw_hardreg *mw2)
    2199                 :             : {
    2200                 :     1627255 :   if (mw1->type != mw2->type)
    2201                 :     1064408 :     return mw1->type - mw2->type;
    2202                 :             : 
    2203                 :      562847 :   if (mw1->flags != mw2->flags)
    2204                 :       28890 :     return mw1->flags - mw2->flags;
    2205                 :             : 
    2206                 :      533957 :   if (mw1->start_regno != mw2->start_regno)
    2207                 :      418191 :     return mw1->start_regno - mw2->start_regno;
    2208                 :             : 
    2209                 :      115766 :   if (mw1->end_regno != mw2->end_regno)
    2210                 :           0 :     return mw1->end_regno - mw2->end_regno;
    2211                 :             : 
    2212                 :      115766 :   return mw1->mw_order - mw2->mw_order;
    2213                 :             : }
    2214                 :             : 
    2215                 :             : /* Like df_mw_compare, but compare two df_mw_hardreg** pointers R1 and R2.  */
    2216                 :             : 
    2217                 :             : static int
    2218                 :     1067928 : df_mw_ptr_compare (const void *m1, const void *m2)
    2219                 :             : {
    2220                 :     1067928 :   return df_mw_compare (*(const df_mw_hardreg *const *) m1,
    2221                 :     1067928 :                         *(const df_mw_hardreg *const *) m2);
    2222                 :             : }
    2223                 :             : 
    2224                 :             : /* Sort and compress a set of refs.  */
    2225                 :             : 
    2226                 :             : static void
    2227                 :  1126730882 : df_sort_and_compress_mws (vec<df_mw_hardreg *, va_heap> *mw_vec)
    2228                 :             : {
    2229                 :  1126730882 :   unsigned int count;
    2230                 :  1126730882 :   struct df_scan_problem_data *problem_data
    2231                 :  1126730882 :     = (struct df_scan_problem_data *) df_scan->problem_data;
    2232                 :  1126730882 :   unsigned int i;
    2233                 :  1126730882 :   unsigned int dist = 0;
    2234                 :             : 
    2235                 :  1126730882 :   count = mw_vec->length ();
    2236                 :  1126730882 :   if (count < 2)
    2237                 :             :     return;
    2238                 :      631746 :   else if (count == 2)
    2239                 :             :     {
    2240                 :      559327 :       struct df_mw_hardreg *m0 = (*mw_vec)[0];
    2241                 :      559327 :       struct df_mw_hardreg *m1 = (*mw_vec)[1];
    2242                 :      559327 :       if (df_mw_compare (m0, m1) > 0)
    2243                 :             :         {
    2244                 :       96198 :           struct df_mw_hardreg *tmp = (*mw_vec)[0];
    2245                 :       96198 :           (*mw_vec)[0] = (*mw_vec)[1];
    2246                 :       96198 :           (*mw_vec)[1] = tmp;
    2247                 :             :         }
    2248                 :             :     }
    2249                 :             :   else
    2250                 :       72419 :     mw_vec->qsort (df_mw_ptr_compare);
    2251                 :             : 
    2252                 :     1968514 :   for (i=0; i<count-dist; i++)
    2253                 :             :     {
    2254                 :             :       /* Find the next ref that is not equal to the current ref.  */
    2255                 :     1359848 :       while (i + dist + 1 < count
    2256                 :     1359848 :              && df_mw_equal_p ((*mw_vec)[i], (*mw_vec)[i + dist + 1]))
    2257                 :             :         {
    2258                 :       23080 :           problem_data->mw_reg_pool->remove ((*mw_vec)[i + dist + 1]);
    2259                 :       23080 :           dist++;
    2260                 :             :         }
    2261                 :             :       /* Copy it down to the next position.  */
    2262                 :     1336768 :       if (dist && i + dist + 1 < count)
    2263                 :        4298 :         (*mw_vec)[i + 1] = (*mw_vec)[i + dist + 1];
    2264                 :             :     }
    2265                 :             : 
    2266                 :      631746 :   count -= dist;
    2267                 :      631746 :   mw_vec->truncate (count);
    2268                 :             : }
    2269                 :             : 
    2270                 :             : 
    2271                 :             : /* Sort and remove duplicates from the COLLECTION_REC.  */
    2272                 :             : 
    2273                 :             : static void
    2274                 :  1126730882 : df_canonize_collection_rec (class df_collection_rec *collection_rec)
    2275                 :             : {
    2276                 :  1126730882 :   df_sort_and_compress_refs (&collection_rec->def_vec);
    2277                 :  1126730882 :   df_sort_and_compress_refs (&collection_rec->use_vec);
    2278                 :  1126730882 :   df_sort_and_compress_refs (&collection_rec->eq_use_vec);
    2279                 :  1126730882 :   df_sort_and_compress_mws (&collection_rec->mw_vec);
    2280                 :  1126730882 : }
    2281                 :             : 
    2282                 :             : 
    2283                 :             : /* Add the new df_ref to appropriate reg_info/ref_info chains.  */
    2284                 :             : 
    2285                 :             : static void
    2286                 :  1754854971 : df_install_ref (df_ref this_ref,
    2287                 :             :                 struct df_reg_info *reg_info,
    2288                 :             :                 struct df_ref_info *ref_info,
    2289                 :             :                 bool add_to_table)
    2290                 :             : {
    2291                 :  1754854971 :   unsigned int regno = DF_REF_REGNO (this_ref);
    2292                 :             :   /* Add the ref to the reg_{def,use,eq_use} chain.  */
    2293                 :  1754854971 :   df_ref head = reg_info->reg_chain;
    2294                 :             : 
    2295                 :  1754854971 :   reg_info->reg_chain = this_ref;
    2296                 :  1754854971 :   reg_info->n_refs++;
    2297                 :             : 
    2298                 :  1754854971 :   if (DF_REF_FLAGS_IS_SET (this_ref, DF_HARD_REG_LIVE))
    2299                 :             :     {
    2300                 :   325696374 :       gcc_assert (regno < FIRST_PSEUDO_REGISTER);
    2301                 :   325696374 :       df->hard_regs_live_count[regno]++;
    2302                 :             :     }
    2303                 :             : 
    2304                 :  1754854971 :   gcc_checking_assert (DF_REF_NEXT_REG (this_ref) == NULL
    2305                 :             :                        && DF_REF_PREV_REG (this_ref) == NULL);
    2306                 :             : 
    2307                 :  1754854971 :   DF_REF_NEXT_REG (this_ref) = head;
    2308                 :             : 
    2309                 :             :   /* We cannot actually link to the head of the chain.  */
    2310                 :  1754854971 :   DF_REF_PREV_REG (this_ref) = NULL;
    2311                 :             : 
    2312                 :  1754854971 :   if (head)
    2313                 :  1425215597 :     DF_REF_PREV_REG (head) = this_ref;
    2314                 :             : 
    2315                 :  1754854971 :   if (add_to_table)
    2316                 :             :     {
    2317                 :     1150222 :       gcc_assert (ref_info->ref_order != DF_REF_ORDER_NO_TABLE);
    2318                 :     1150222 :       df_check_and_grow_ref_info (ref_info, 1);
    2319                 :     1150222 :       DF_REF_ID (this_ref) = ref_info->table_size;
    2320                 :             :       /* Add the ref to the big array of defs.  */
    2321                 :     1150222 :       ref_info->refs[ref_info->table_size] = this_ref;
    2322                 :     1150222 :       ref_info->table_size++;
    2323                 :             :     }
    2324                 :             :   else
    2325                 :  1753704749 :     DF_REF_ID (this_ref) = -1;
    2326                 :             : 
    2327                 :  1754854971 :   ref_info->total_size++;
    2328                 :  1754854971 : }
    2329                 :             : 
    2330                 :             : 
    2331                 :             : /* This function takes one of the groups of refs (defs, uses or
    2332                 :             :    eq_uses) and installs the entire group into the insn.  It also adds
    2333                 :             :    each of these refs into the appropriate chains.  */
    2334                 :             : 
    2335                 :             : static df_ref
    2336                 :  1114362873 : df_install_refs (basic_block bb,
    2337                 :             :                  const vec<df_ref, va_heap> *old_vec,
    2338                 :             :                  struct df_reg_info **reg_info,
    2339                 :             :                  struct df_ref_info *ref_info,
    2340                 :             :                  bool is_notes)
    2341                 :             : {
    2342                 :  1114362873 :   unsigned int count = old_vec->length ();
    2343                 :  1114362873 :   if (count)
    2344                 :             :     {
    2345                 :   462290633 :       bool add_to_table;
    2346                 :   462290633 :       df_ref this_ref;
    2347                 :   462290633 :       unsigned int ix;
    2348                 :             : 
    2349                 :   462290633 :       switch (ref_info->ref_order)
    2350                 :             :         {
    2351                 :           0 :         case DF_REF_ORDER_UNORDERED_WITH_NOTES:
    2352                 :           0 :         case DF_REF_ORDER_BY_REG_WITH_NOTES:
    2353                 :           0 :         case DF_REF_ORDER_BY_INSN_WITH_NOTES:
    2354                 :           0 :           ref_info->ref_order = DF_REF_ORDER_UNORDERED_WITH_NOTES;
    2355                 :           0 :           add_to_table = true;
    2356                 :           0 :           break;
    2357                 :     1853410 :         case DF_REF_ORDER_UNORDERED:
    2358                 :     1853410 :         case DF_REF_ORDER_BY_REG:
    2359                 :     1853410 :         case DF_REF_ORDER_BY_INSN:
    2360                 :     1853410 :           ref_info->ref_order = DF_REF_ORDER_UNORDERED;
    2361                 :     1853410 :           add_to_table = !is_notes;
    2362                 :     1853410 :           break;
    2363                 :             :         default:
    2364                 :             :           add_to_table = false;
    2365                 :             :           break;
    2366                 :             :         }
    2367                 :             : 
    2368                 :             :       /* Do not add if ref is not in the right blocks.  */
    2369                 :     1853410 :       if (add_to_table && df->analyze_subset)
    2370                 :     1206081 :         add_to_table = bitmap_bit_p (df->blocks_to_analyze, bb->index);
    2371                 :             : 
    2372                 :  2217145604 :       FOR_EACH_VEC_ELT (*old_vec, ix, this_ref)
    2373                 :             :         {
    2374                 :  1754854971 :           DF_REF_NEXT_LOC (this_ref) = (ix + 1 < old_vec->length ()
    2375                 :  1754854971 :                                         ? (*old_vec)[ix + 1]
    2376                 :             :                                         : NULL);
    2377                 :  1754854971 :           df_install_ref (this_ref, reg_info[DF_REF_REGNO (this_ref)],
    2378                 :             :                           ref_info, add_to_table);
    2379                 :             :         }
    2380                 :   462290633 :       return (*old_vec)[0];
    2381                 :             :     }
    2382                 :             :   else
    2383                 :             :     return 0;
    2384                 :             : }
    2385                 :             : 
    2386                 :             : 
    2387                 :             : /* This function takes the mws installs the entire group into the
    2388                 :             :    insn.  */
    2389                 :             : 
    2390                 :             : static struct df_mw_hardreg *
    2391                 :   336020160 : df_install_mws (const vec<df_mw_hardreg *, va_heap> *old_vec)
    2392                 :             : {
    2393                 :   336020160 :   unsigned int count = old_vec->length ();
    2394                 :   336020160 :   if (count)
    2395                 :             :     {
    2396                 :     3080195 :       for (unsigned int i = 0; i < count - 1; i++)
    2397                 :      281548 :         DF_MWS_NEXT ((*old_vec)[i]) = (*old_vec)[i + 1];
    2398                 :     2798647 :       DF_MWS_NEXT ((*old_vec)[count - 1]) = 0;
    2399                 :     2798647 :       return (*old_vec)[0];
    2400                 :             :     }
    2401                 :             :   else
    2402                 :             :     return 0;
    2403                 :             : }
    2404                 :             : 
    2405                 :             : 
    2406                 :             : /* Add a chain of df_refs to appropriate ref chain/reg_info/ref_info
    2407                 :             :    chains and update other necessary information.  */
    2408                 :             : 
    2409                 :             : static void
    2410                 :   400440782 : df_refs_add_to_chains (class df_collection_rec *collection_rec,
    2411                 :             :                        basic_block bb, rtx_insn *insn, unsigned int flags)
    2412                 :             : {
    2413                 :   400440782 :   if (insn)
    2414                 :             :     {
    2415                 :   358559011 :       struct df_insn_info *insn_rec = DF_INSN_INFO_GET (insn);
    2416                 :             :       /* If there is a vector in the collection rec, add it to the
    2417                 :             :          insn.  A null rec is a signal that the caller will handle the
    2418                 :             :          chain specially.  */
    2419                 :   358559011 :       if (flags & copy_defs)
    2420                 :             :         {
    2421                 :   336020160 :           gcc_checking_assert (!insn_rec->defs);
    2422                 :   336020160 :           insn_rec->defs
    2423                 :   336020160 :             = df_install_refs (bb, &collection_rec->def_vec,
    2424                 :             :                                df->def_regs,
    2425                 :             :                                &df->def_info, false);
    2426                 :             :         }
    2427                 :   358559011 :       if (flags & copy_uses)
    2428                 :             :         {
    2429                 :   336020160 :           gcc_checking_assert (!insn_rec->uses);
    2430                 :   336020160 :           insn_rec->uses
    2431                 :   336020160 :             = df_install_refs (bb, &collection_rec->use_vec,
    2432                 :             :                                df->use_regs,
    2433                 :   336020160 :                                &df->use_info, false);
    2434                 :             :         }
    2435                 :   358559011 :       if (flags & copy_eq_uses)
    2436                 :             :         {
    2437                 :   358559011 :           gcc_checking_assert (!insn_rec->eq_uses);
    2438                 :   358559011 :           insn_rec->eq_uses
    2439                 :   358559011 :             = df_install_refs (bb, &collection_rec->eq_use_vec,
    2440                 :             :                                df->eq_use_regs,
    2441                 :   358559011 :                                &df->use_info, true);
    2442                 :             :         }
    2443                 :   358559011 :       if (flags & copy_mw)
    2444                 :             :         {
    2445                 :   336020160 :           gcc_checking_assert (!insn_rec->mw_hardregs);
    2446                 :   336020160 :           insn_rec->mw_hardregs
    2447                 :   336020160 :             = df_install_mws (&collection_rec->mw_vec);
    2448                 :             :         }
    2449                 :             :     }
    2450                 :             :   else
    2451                 :             :     {
    2452                 :    41881771 :       struct df_scan_bb_info *bb_info = df_scan_get_bb_info (bb->index);
    2453                 :             : 
    2454                 :    41881771 :       gcc_checking_assert (!bb_info->artificial_defs);
    2455                 :    41881771 :       bb_info->artificial_defs
    2456                 :    41881771 :         = df_install_refs (bb, &collection_rec->def_vec,
    2457                 :             :                            df->def_regs,
    2458                 :             :                            &df->def_info, false);
    2459                 :    41881771 :       gcc_checking_assert (!bb_info->artificial_uses);
    2460                 :    41881771 :       bb_info->artificial_uses
    2461                 :    41881771 :         = df_install_refs (bb, &collection_rec->use_vec,
    2462                 :             :                            df->use_regs,
    2463                 :    41881771 :                            &df->use_info, false);
    2464                 :             :     }
    2465                 :   400440782 : }
    2466                 :             : 
    2467                 :             : 
    2468                 :             : /* Allocate a ref and initialize its fields.  */
    2469                 :             : 
    2470                 :             : static df_ref
    2471                 :  7106041817 : df_ref_create_structure (enum df_ref_class cl,
    2472                 :             :                          class df_collection_rec *collection_rec,
    2473                 :             :                          rtx reg, rtx *loc,
    2474                 :             :                          basic_block bb, struct df_insn_info *info,
    2475                 :             :                          enum df_ref_type ref_type,
    2476                 :             :                          int ref_flags)
    2477                 :             : {
    2478                 :  7106041817 :   const unsigned int regno
    2479                 :  7106041817 :     = REGNO (GET_CODE (reg) == SUBREG ? SUBREG_REG (reg) : reg);
    2480                 :  7106041817 :   struct df_scan_problem_data *problem_data
    2481                 :  7106041817 :     = (struct df_scan_problem_data *) df_scan->problem_data;
    2482                 :  7106041817 :   df_ref this_ref;
    2483                 :             : 
    2484                 :  7106041817 :   switch (cl)
    2485                 :             :     {
    2486                 :  5226897994 :     case DF_REF_BASE:
    2487                 :  5226897994 :       this_ref = (df_ref) (problem_data->ref_base_pool->allocate ());
    2488                 :  5226897994 :       gcc_checking_assert (loc == NULL);
    2489                 :             :       break;
    2490                 :             : 
    2491                 :   465397926 :     case DF_REF_ARTIFICIAL:
    2492                 :   465397926 :       this_ref = (df_ref) (problem_data->ref_artificial_pool->allocate ());
    2493                 :   465397926 :       this_ref->artificial_ref.bb = bb;
    2494                 :   465397926 :       gcc_checking_assert (loc == NULL);
    2495                 :             :       break;
    2496                 :             : 
    2497                 :  1413745897 :     case DF_REF_REGULAR:
    2498                 :  1413745897 :       this_ref = (df_ref) (problem_data->ref_regular_pool->allocate ());
    2499                 :  1413745897 :       this_ref->regular_ref.loc = loc;
    2500                 :  1413745897 :       gcc_checking_assert (loc);
    2501                 :             :       break;
    2502                 :             : 
    2503                 :           0 :     default:
    2504                 :           0 :       gcc_unreachable ();
    2505                 :             :     }
    2506                 :             : 
    2507                 :  7106041817 :   DF_REF_CLASS (this_ref) = cl;
    2508                 :  7106041817 :   DF_REF_ID (this_ref) = -1;
    2509                 :  7106041817 :   DF_REF_REG (this_ref) = reg;
    2510                 :  7106041817 :   DF_REF_REGNO (this_ref) = regno;
    2511                 :  7106041817 :   DF_REF_TYPE (this_ref) = ref_type;
    2512                 :  7106041817 :   DF_REF_INSN_INFO (this_ref) = info;
    2513                 :  7106041817 :   DF_REF_CHAIN (this_ref) = NULL;
    2514                 :  7106041817 :   DF_REF_FLAGS (this_ref) = ref_flags;
    2515                 :  7106041817 :   DF_REF_NEXT_REG (this_ref) = NULL;
    2516                 :  7106041817 :   DF_REF_PREV_REG (this_ref) = NULL;
    2517                 :  7106041817 :   DF_REF_ORDER (this_ref) = df->ref_order++;
    2518                 :             : 
    2519                 :             :   /* We need to clear the DF_HARD_REG_LIVE bit because fwprop, and in the
    2520                 :             :      future possibly other optimizations, sometimes create new refs using
    2521                 :             :      live refs as the model.  */
    2522                 :  7106041817 :   DF_REF_FLAGS_CLEAR (this_ref, DF_HARD_REG_LIVE);
    2523                 :             : 
    2524                 :             :   /* Now see if this ref really needs to have the bit set.  */
    2525                 :  7106041817 :   if (regno < FIRST_PSEUDO_REGISTER
    2526                 :  7106041817 :       && cl != DF_REF_ARTIFICIAL
    2527                 :  6267286790 :       && !DEBUG_INSN_P (info->insn))
    2528                 :             :     {
    2529                 :  6220647074 :       if (ref_type == DF_REF_REG_DEF)
    2530                 :             :         {
    2531                 :  5558931647 :           if (!DF_REF_FLAGS_IS_SET (this_ref, DF_REF_MAY_CLOBBER))
    2532                 :   414529719 :             DF_REF_FLAGS_SET (this_ref, DF_HARD_REG_LIVE);
    2533                 :             :         }
    2534                 :   661715427 :       else if (!(TEST_HARD_REG_BIT (elim_reg_set, regno)
    2535                 :    66055013 :                  && (regno == FRAME_POINTER_REGNUM
    2536                 :    66055013 :                      || regno == ARG_POINTER_REGNUM)))
    2537                 :   595660414 :         DF_REF_FLAGS_SET (this_ref, DF_HARD_REG_LIVE);
    2538                 :             :     }
    2539                 :             : 
    2540                 :  7106041817 :   if (collection_rec)
    2541                 :             :     {
    2542                 :  7106041817 :       if (DF_REF_REG_DEF_P (this_ref))
    2543                 :  5876252786 :         collection_rec->def_vec.safe_push (this_ref);
    2544                 :  1229789031 :       else if (DF_REF_FLAGS (this_ref) & DF_REF_IN_NOTE)
    2545                 :    39485831 :         collection_rec->eq_use_vec.safe_push (this_ref);
    2546                 :             :       else
    2547                 :  1190303200 :         collection_rec->use_vec.safe_push (this_ref);
    2548                 :             :     }
    2549                 :             :   else
    2550                 :           0 :     df_install_ref_incremental (this_ref);
    2551                 :             : 
    2552                 :  7106041817 :   return this_ref;
    2553                 :             : }
    2554                 :             : 
    2555                 :             : 
    2556                 :             : /* Create new references of type DF_REF_TYPE for each part of register REG
    2557                 :             :    at address LOC within INSN of BB.  */
    2558                 :             : 
    2559                 :             : 
    2560                 :             : static void
    2561                 :  7098222299 : df_ref_record (enum df_ref_class cl,
    2562                 :             :                class df_collection_rec *collection_rec,
    2563                 :             :                rtx reg, rtx *loc,
    2564                 :             :                basic_block bb, struct df_insn_info *insn_info,
    2565                 :             :                enum df_ref_type ref_type,
    2566                 :             :                int ref_flags)
    2567                 :             : {
    2568                 :  7098222299 :   unsigned int regno;
    2569                 :             : 
    2570                 :  7098222299 :   gcc_checking_assert (REG_P (reg) || GET_CODE (reg) == SUBREG);
    2571                 :             : 
    2572                 :  7098222299 :   regno = REGNO (GET_CODE (reg) == SUBREG ? SUBREG_REG (reg) : reg);
    2573                 :  7098222299 :   if (regno < FIRST_PSEUDO_REGISTER)
    2574                 :             :     {
    2575                 :  6724865198 :       struct df_mw_hardreg *hardreg = NULL;
    2576                 :  6724865198 :       struct df_scan_problem_data *problem_data
    2577                 :  6724865198 :         = (struct df_scan_problem_data *) df_scan->problem_data;
    2578                 :  6724865198 :       unsigned int i;
    2579                 :  6724865198 :       unsigned int endregno;
    2580                 :  6724865198 :       df_ref ref;
    2581                 :             : 
    2582                 :  6724865198 :       if (GET_CODE (reg) == SUBREG)
    2583                 :             :         {
    2584                 :      253442 :           int off = subreg_regno_offset (regno, GET_MODE (SUBREG_REG (reg)),
    2585                 :      126721 :                                          SUBREG_BYTE (reg), GET_MODE (reg));
    2586                 :      126721 :           unsigned int nregno = regno + off;
    2587                 :      126721 :           endregno = nregno + subreg_nregs (reg);
    2588                 :      126721 :           if (off < 0 && regno < (unsigned) -off)
    2589                 :             :             /* Deal with paradoxical SUBREGs on big endian where
    2590                 :             :                in debug insns the hard reg number might be smaller
    2591                 :             :                than -off, such as (subreg:DI (reg:SI 0 [+4 ]) 0));
    2592                 :             :                RA decisions shouldn't be affected by debug insns
    2593                 :             :                and so RA can decide to put pseudo into a hard reg
    2594                 :             :                with small REGNO, even when it is referenced in
    2595                 :             :                a paradoxical SUBREG in a debug insn.  */
    2596                 :             :             regno = 0;
    2597                 :             :           else
    2598                 :      126721 :             regno = nregno;
    2599                 :             :         }
    2600                 :             :       else
    2601                 :  6724738477 :         endregno = END_REGNO (reg);
    2602                 :             : 
    2603                 :             :       /*  If this is a multiword hardreg, we create some extra
    2604                 :             :           datastructures that will enable us to easily build REG_DEAD
    2605                 :             :           and REG_UNUSED notes.  */
    2606                 :  6724865198 :       if (collection_rec
    2607                 :  6724865198 :           && (endregno != regno + 1) && insn_info)
    2608                 :             :         {
    2609                 :             :           /* Sets to a subreg of a multiword register are partial.
    2610                 :             :              Sets to a non-subreg of a multiword register are not.  */
    2611                 :     7816974 :           if (GET_CODE (reg) == SUBREG)
    2612                 :           0 :             ref_flags |= DF_REF_PARTIAL;
    2613                 :     7816974 :           ref_flags |= DF_REF_MW_HARDREG;
    2614                 :             : 
    2615                 :     7816974 :           gcc_assert (regno < endregno);
    2616                 :             : 
    2617                 :     7816974 :           hardreg = problem_data->mw_reg_pool->allocate ();
    2618                 :     7816974 :           hardreg->type = ref_type;
    2619                 :     7816974 :           hardreg->flags = ref_flags;
    2620                 :     7816974 :           hardreg->mw_reg = reg;
    2621                 :     7816974 :           hardreg->start_regno = regno;
    2622                 :     7816974 :           hardreg->end_regno = endregno - 1;
    2623                 :     7816974 :           hardreg->mw_order = df->ref_order++;
    2624                 :     7816974 :           collection_rec->mw_vec.safe_push (hardreg);
    2625                 :             :         }
    2626                 :             : 
    2627                 : 13457549914 :       for (i = regno; i < endregno; i++)
    2628                 :             :         {
    2629                 :  6732684716 :           ref = df_ref_create_structure (cl, collection_rec, regno_reg_rtx[i], loc,
    2630                 :             :                                          bb, insn_info, ref_type, ref_flags);
    2631                 :             : 
    2632                 :  6732684716 :           gcc_assert (ORIGINAL_REGNO (DF_REF_REG (ref)) == i);
    2633                 :             :         }
    2634                 :             :     }
    2635                 :             :   else
    2636                 :             :     {
    2637                 :   373357101 :       df_ref_create_structure (cl, collection_rec, reg, loc, bb, insn_info,
    2638                 :             :                                ref_type, ref_flags);
    2639                 :             :     }
    2640                 :  7098222299 : }
    2641                 :             : 
    2642                 :             : 
    2643                 :             : /* Process all the registers defined in the rtx pointed by LOC.
    2644                 :             :    Autoincrement/decrement definitions will be picked up by df_uses_record.
    2645                 :             :    Any change here has to be matched in df_find_hard_reg_defs_1.  */
    2646                 :             : 
    2647                 :             : static void
    2648                 :   706823623 : df_def_record_1 (class df_collection_rec *collection_rec,
    2649                 :             :                  rtx *loc, basic_block bb, struct df_insn_info *insn_info,
    2650                 :             :                  int flags)
    2651                 :             : {
    2652                 :   706823623 :   rtx dst = *loc;
    2653                 :             : 
    2654                 :             :   /* It is legal to have a set destination be a parallel. */
    2655                 :   706823623 :   if (GET_CODE (dst) == PARALLEL)
    2656                 :             :     {
    2657                 :      112565 :       int i;
    2658                 :      308385 :       for (i = XVECLEN (dst, 0) - 1; i >= 0; i--)
    2659                 :             :         {
    2660                 :      195820 :           rtx temp = XVECEXP (dst, 0, i);
    2661                 :      195820 :           gcc_assert (GET_CODE (temp) == EXPR_LIST);
    2662                 :      195820 :           df_def_record_1 (collection_rec, &XEXP (temp, 0),
    2663                 :             :                            bb, insn_info, flags);
    2664                 :             :         }
    2665                 :             :       return;
    2666                 :             :     }
    2667                 :             : 
    2668                 :   706711058 :   if (GET_CODE (dst) == STRICT_LOW_PART)
    2669                 :             :     {
    2670                 :      108287 :       flags |= DF_REF_READ_WRITE | DF_REF_PARTIAL | DF_REF_STRICT_LOW_PART;
    2671                 :             : 
    2672                 :      108287 :       loc = &XEXP (dst, 0);
    2673                 :      108287 :       dst = *loc;
    2674                 :             :     }
    2675                 :             : 
    2676                 :   706711058 :   if (GET_CODE (dst) == ZERO_EXTRACT)
    2677                 :             :     {
    2678                 :       69029 :       flags |= DF_REF_READ_WRITE | DF_REF_PARTIAL | DF_REF_ZERO_EXTRACT;
    2679                 :             : 
    2680                 :       69029 :       loc = &XEXP (dst, 0);
    2681                 :       69029 :       dst = *loc;
    2682                 :             :     }
    2683                 :             : 
    2684                 :             :   /* At this point if we do not have a reg or a subreg, just return.  */
    2685                 :   706711058 :   if (REG_P (dst))
    2686                 :             :     {
    2687                 :   524624735 :       df_ref_record (DF_REF_REGULAR, collection_rec,
    2688                 :             :                      dst, loc, bb, insn_info, DF_REF_REG_DEF, flags);
    2689                 :             : 
    2690                 :             :       /* We want to keep sp alive everywhere - by making all
    2691                 :             :          writes to sp also use of sp. */
    2692                 :   524624735 :       if (REGNO (dst) == STACK_POINTER_REGNUM)
    2693                 :    19218047 :         df_ref_record (DF_REF_BASE, collection_rec,
    2694                 :             :                        dst, NULL, bb, insn_info, DF_REF_REG_USE, flags);
    2695                 :             :     }
    2696                 :   182086323 :   else if (GET_CODE (dst) == SUBREG && REG_P (SUBREG_REG (dst)))
    2697                 :             :     {
    2698                 :     2502490 :       if (read_modify_subreg_p (dst))
    2699                 :     1104521 :         flags |= DF_REF_READ_WRITE | DF_REF_PARTIAL;
    2700                 :             : 
    2701                 :     2502490 :       flags |= DF_REF_SUBREG;
    2702                 :             : 
    2703                 :     2502490 :       df_ref_record (DF_REF_REGULAR, collection_rec,
    2704                 :             :                      dst, loc, bb, insn_info, DF_REF_REG_DEF, flags);
    2705                 :             :     }
    2706                 :             : }
    2707                 :             : 
    2708                 :             : 
    2709                 :             : /* Process all the registers defined in the pattern rtx, X.  Any change
    2710                 :             :    here has to be matched in df_find_hard_reg_defs.  */
    2711                 :             : 
    2712                 :             : static void
    2713                 :  1168085090 : df_defs_record (class df_collection_rec *collection_rec,
    2714                 :             :                 rtx x, basic_block bb, struct df_insn_info *insn_info,
    2715                 :             :                 int flags)
    2716                 :             : {
    2717                 :  1168085090 :   RTX_CODE code = GET_CODE (x);
    2718                 :  1168085090 :   int i;
    2719                 :             : 
    2720                 :  1168085090 :   switch (code)
    2721                 :             :     {
    2722                 :   615080777 :     case SET:
    2723                 :   615080777 :       df_def_record_1 (collection_rec, &SET_DEST (x), bb, insn_info, flags);
    2724                 :   615080777 :       break;
    2725                 :             : 
    2726                 :    91547026 :     case CLOBBER:
    2727                 :    91547026 :       flags |= DF_REF_MUST_CLOBBER;
    2728                 :    91547026 :       df_def_record_1 (collection_rec, &XEXP (x, 0), bb, insn_info, flags);
    2729                 :    91547026 :       break;
    2730                 :             : 
    2731                 :           0 :     case COND_EXEC:
    2732                 :           0 :       df_defs_record (collection_rec, COND_EXEC_CODE (x),
    2733                 :             :                       bb, insn_info, DF_REF_CONDITIONAL);
    2734                 :           0 :       break;
    2735                 :             : 
    2736                 :             :     case PARALLEL:
    2737                 :   257737275 :       for (i = 0; i < XVECLEN (x, 0); i++)
    2738                 :   174594715 :         df_defs_record (collection_rec, XVECEXP (x, 0, i),
    2739                 :             :                         bb, insn_info, flags);
    2740                 :             :       break;
    2741                 :             :     default:
    2742                 :             :       /* No DEFs to record in other cases */
    2743                 :             :       break;
    2744                 :             :     }
    2745                 :  1168085090 : }
    2746                 :             : 
    2747                 :             : /* Set bits in *DEFS for hard registers found in the rtx DST, which is the
    2748                 :             :    destination of a set or clobber.  This has to match the logic in
    2749                 :             :    df_defs_record_1.  */
    2750                 :             : 
    2751                 :             : static void
    2752                 :    27508959 : df_find_hard_reg_defs_1 (rtx dst, HARD_REG_SET *defs)
    2753                 :             : {
    2754                 :             :   /* It is legal to have a set destination be a parallel. */
    2755                 :    27508959 :   if (GET_CODE (dst) == PARALLEL)
    2756                 :             :     {
    2757                 :      112565 :       int i;
    2758                 :      308385 :       for (i = XVECLEN (dst, 0) - 1; i >= 0; i--)
    2759                 :             :         {
    2760                 :      195820 :           rtx temp = XVECEXP (dst, 0, i);
    2761                 :      195820 :           gcc_assert (GET_CODE (temp) == EXPR_LIST);
    2762                 :      195820 :           df_find_hard_reg_defs_1 (XEXP (temp, 0), defs);
    2763                 :             :         }
    2764                 :             :       return;
    2765                 :             :     }
    2766                 :             : 
    2767                 :    27396394 :   if (GET_CODE (dst) == STRICT_LOW_PART)
    2768                 :           0 :       dst = XEXP (dst, 0);
    2769                 :             : 
    2770                 :    27396394 :   if (GET_CODE (dst) == ZERO_EXTRACT)
    2771                 :           0 :       dst = XEXP (dst, 0);
    2772                 :             : 
    2773                 :             :   /* At this point if we do not have a reg or a subreg, just return.  */
    2774                 :    27396394 :   if (REG_P (dst) && HARD_REGISTER_P (dst))
    2775                 :    27396394 :     SET_HARD_REG_BIT (*defs, REGNO (dst));
    2776                 :           0 :   else if (GET_CODE (dst) == SUBREG
    2777                 :           0 :            && REG_P (SUBREG_REG (dst)) && HARD_REGISTER_P (dst))
    2778                 :           0 :     SET_HARD_REG_BIT (*defs, REGNO (SUBREG_REG (dst)));
    2779                 :             : }
    2780                 :             : 
    2781                 :             : /* Set bits in *DEFS for hard registers defined in the pattern X.  This
    2782                 :             :    has to match the logic in df_defs_record.  */
    2783                 :             : 
    2784                 :             : static void
    2785                 :    67190605 : df_find_hard_reg_defs (rtx x, HARD_REG_SET *defs)
    2786                 :             : {
    2787                 :    67190605 :   RTX_CODE code = GET_CODE (x);
    2788                 :    67190605 :   int i;
    2789                 :             : 
    2790                 :    67190605 :   switch (code)
    2791                 :             :     {
    2792                 :    27313139 :     case SET:
    2793                 :    27313139 :       df_find_hard_reg_defs_1 (SET_DEST (x), defs);
    2794                 :    27313139 :       break;
    2795                 :             : 
    2796                 :           0 :     case CLOBBER:
    2797                 :           0 :       df_find_hard_reg_defs_1 (XEXP (x, 0), defs);
    2798                 :           0 :       break;
    2799                 :             : 
    2800                 :           0 :     case COND_EXEC:
    2801                 :           0 :       df_find_hard_reg_defs (COND_EXEC_CODE (x), defs);
    2802                 :           0 :       break;
    2803                 :             : 
    2804                 :             :     case PARALLEL:
    2805                 :     5753832 :       for (i = 0; i < XVECLEN (x, 0); i++)
    2806                 :     3835888 :         df_find_hard_reg_defs (XVECEXP (x, 0, i), defs);
    2807                 :             :       break;
    2808                 :             :     default:
    2809                 :             :       /* No DEFs to record in other cases */
    2810                 :             :       break;
    2811                 :             :     }
    2812                 :    67190605 : }
    2813                 :             : 
    2814                 :             : 
    2815                 :             : /* Process all the registers used in the rtx at address LOC.  */
    2816                 :             : 
    2817                 :             : static void
    2818                 :  2602814605 : df_uses_record (class df_collection_rec *collection_rec,
    2819                 :             :                 rtx *loc, enum df_ref_type ref_type,
    2820                 :             :                 basic_block bb, struct df_insn_info *insn_info,
    2821                 :             :                 int flags)
    2822                 :             : {
    2823                 :  3777902282 :   RTX_CODE code;
    2824                 :  3777902282 :   rtx x;
    2825                 :             : 
    2826                 :  3777902282 :  retry:
    2827                 :  3777902282 :   x = *loc;
    2828                 :  3777902282 :   if (!x)
    2829                 :             :     return;
    2830                 :  3777902282 :   code = GET_CODE (x);
    2831                 :  3777902282 :   switch (code)
    2832                 :             :     {
    2833                 :             :     case LABEL_REF:
    2834                 :             :     case SYMBOL_REF:
    2835                 :             :     case CONST:
    2836                 :             :     CASE_CONST_ANY:
    2837                 :             :     case PC:
    2838                 :             :     case ADDR_VEC:
    2839                 :             :     case ADDR_DIFF_VEC:
    2840                 :             :       return;
    2841                 :             : 
    2842                 :   188388382 :     case CLOBBER:
    2843                 :             :       /* If we are clobbering a MEM, mark any registers inside the address
    2844                 :             :          as being used.  */
    2845                 :   188388382 :       if (MEM_P (XEXP (x, 0)))
    2846                 :     3449933 :         df_uses_record (collection_rec,
    2847                 :             :                         &XEXP (XEXP (x, 0), 0),
    2848                 :             :                         DF_REF_REG_MEM_STORE,
    2849                 :             :                         bb, insn_info,
    2850                 :             :                         flags);
    2851                 :             : 
    2852                 :             :       /* If we're clobbering a REG then we have a def so ignore.  */
    2853                 :             :       return;
    2854                 :             : 
    2855                 :   208781807 :     case MEM:
    2856                 :   208781807 :       df_uses_record (collection_rec,
    2857                 :             :                       &XEXP (x, 0), DF_REF_REG_MEM_LOAD,
    2858                 :             :                       bb, insn_info, flags & DF_REF_IN_NOTE);
    2859                 :   208781807 :       return;
    2860                 :             : 
    2861                 :     9976755 :     case SUBREG:
    2862                 :             :       /* While we're here, optimize this case.  */
    2863                 :     9976755 :       flags |= DF_REF_PARTIAL;
    2864                 :             :       /* In case the SUBREG is not of a REG, do not optimize.  */
    2865                 :     9976755 :       if (!REG_P (SUBREG_REG (x)))
    2866                 :             :         {
    2867                 :      701539 :           loc = &SUBREG_REG (x);
    2868                 :      701539 :           df_uses_record (collection_rec, loc, ref_type, bb, insn_info, flags);
    2869                 :      701539 :           return;
    2870                 :             :         }
    2871                 :             :       /* Fall through */
    2872                 :             : 
    2873                 :   857253410 :     case REG:
    2874                 :   857253410 :       df_ref_record (DF_REF_REGULAR, collection_rec,
    2875                 :             :                      x, loc, bb, insn_info,
    2876                 :             :                      ref_type, flags);
    2877                 :   857253410 :       return;
    2878                 :             : 
    2879                 :      325846 :     case SIGN_EXTRACT:
    2880                 :      325846 :     case ZERO_EXTRACT:
    2881                 :      325846 :       {
    2882                 :      325846 :         df_uses_record (collection_rec,
    2883                 :             :                         &XEXP (x, 1), ref_type, bb, insn_info, flags);
    2884                 :      325846 :         df_uses_record (collection_rec,
    2885                 :             :                         &XEXP (x, 2), ref_type, bb, insn_info, flags);
    2886                 :             : 
    2887                 :             :         /* If the parameters to the zero or sign extract are
    2888                 :             :            constants, strip them off and recurse, otherwise there is
    2889                 :             :            no information that we can gain from this operation.  */
    2890                 :      325846 :         if (code == ZERO_EXTRACT)
    2891                 :      306591 :           flags |= DF_REF_ZERO_EXTRACT;
    2892                 :             :         else
    2893                 :       19255 :           flags |= DF_REF_SIGN_EXTRACT;
    2894                 :             : 
    2895                 :      325846 :         df_uses_record (collection_rec,
    2896                 :             :                         &XEXP (x, 0), ref_type, bb, insn_info, flags);
    2897                 :      325846 :         return;
    2898                 :             :       }
    2899                 :   615080777 :       break;
    2900                 :             : 
    2901                 :   615080777 :     case SET:
    2902                 :   615080777 :       {
    2903                 :   615080777 :         rtx dst = SET_DEST (x);
    2904                 :   615080777 :         gcc_assert (!(flags & DF_REF_IN_NOTE));
    2905                 :   615080777 :         df_uses_record (collection_rec,
    2906                 :             :                         &SET_SRC (x), DF_REF_REG_USE, bb, insn_info, flags);
    2907                 :             : 
    2908                 :   615080777 :         switch (GET_CODE (dst))
    2909                 :             :           {
    2910                 :     2475613 :             case SUBREG:
    2911                 :     2475613 :               if (read_modify_subreg_p (dst))
    2912                 :             :                 {
    2913                 :     1095856 :                   df_uses_record (collection_rec, &SUBREG_REG (dst),
    2914                 :             :                                   DF_REF_REG_USE, bb, insn_info,
    2915                 :             :                                   flags | DF_REF_READ_WRITE | DF_REF_SUBREG);
    2916                 :     1095856 :                   break;
    2917                 :             :                 }
    2918                 :             :               /* Fall through.  */
    2919                 :             :             case REG:
    2920                 :             :             case PARALLEL:
    2921                 :             :             case SCRATCH:
    2922                 :             :             case PC:
    2923                 :             :                 break;
    2924                 :   103021783 :             case MEM:
    2925                 :   103021783 :               df_uses_record (collection_rec, &XEXP (dst, 0),
    2926                 :             :                               DF_REF_REG_MEM_STORE, bb, insn_info, flags);
    2927                 :   103021783 :               break;
    2928                 :      108287 :             case STRICT_LOW_PART:
    2929                 :      108287 :               {
    2930                 :      108287 :                 rtx *temp = &XEXP (dst, 0);
    2931                 :             :                 /* A strict_low_part uses the whole REG and not just the
    2932                 :             :                  SUBREG.  */
    2933                 :      108287 :                 dst = XEXP (dst, 0);
    2934                 :       22131 :                 df_uses_record (collection_rec,
    2935                 :      108287 :                                 (GET_CODE (dst) == SUBREG) ? &SUBREG_REG (dst) : temp,
    2936                 :             :                                 DF_REF_REG_USE, bb, insn_info,
    2937                 :             :                                 DF_REF_READ_WRITE | DF_REF_STRICT_LOW_PART);
    2938                 :             :               }
    2939                 :      108287 :               break;
    2940                 :       69029 :             case ZERO_EXTRACT:
    2941                 :       69029 :               {
    2942                 :       69029 :                 df_uses_record (collection_rec, &XEXP (dst, 1),
    2943                 :             :                                 DF_REF_REG_USE, bb, insn_info, flags);
    2944                 :       69029 :                 df_uses_record (collection_rec, &XEXP (dst, 2),
    2945                 :             :                                 DF_REF_REG_USE, bb, insn_info, flags);
    2946                 :       69029 :                 if (GET_CODE (XEXP (dst,0)) == MEM)
    2947                 :        4595 :                   df_uses_record (collection_rec, &XEXP (dst, 0),
    2948                 :             :                                   DF_REF_REG_USE, bb, insn_info,
    2949                 :             :                                   flags);
    2950                 :             :                 else
    2951                 :       64434 :                   df_uses_record (collection_rec, &XEXP (dst, 0),
    2952                 :             :                                   DF_REF_REG_USE, bb, insn_info,
    2953                 :             :                                   DF_REF_READ_WRITE | DF_REF_ZERO_EXTRACT);
    2954                 :             :               }
    2955                 :             :               break;
    2956                 :             : 
    2957                 :           0 :             default:
    2958                 :           0 :               gcc_unreachable ();
    2959                 :             :           }
    2960                 :             :         return;
    2961                 :             :       }
    2962                 :             : 
    2963                 :             :     case RETURN:
    2964                 :             :     case SIMPLE_RETURN:
    2965                 :             :       break;
    2966                 :             : 
    2967                 :     5955825 :     case ASM_OPERANDS:
    2968                 :     5955825 :     case UNSPEC_VOLATILE:
    2969                 :     5955825 :     case TRAP_IF:
    2970                 :     5955825 :     case ASM_INPUT:
    2971                 :     5955825 :       {
    2972                 :             :         /* Traditional and volatile asm instructions must be
    2973                 :             :            considered to use and clobber all hard registers, all
    2974                 :             :            pseudo-registers and all of memory.  So must TRAP_IF and
    2975                 :             :            UNSPEC_VOLATILE operations.
    2976                 :             : 
    2977                 :             :            Consider for instance a volatile asm that changes the fpu
    2978                 :             :            rounding mode.  An insn should not be moved across this
    2979                 :             :            even if it only uses pseudo-regs because it might give an
    2980                 :             :            incorrectly rounded result.
    2981                 :             : 
    2982                 :             :            However, flow.c's liveness computation did *not* do this,
    2983                 :             :            giving the reasoning as " ?!? Unfortunately, marking all
    2984                 :             :            hard registers as live causes massive problems for the
    2985                 :             :            register allocator and marking all pseudos as live creates
    2986                 :             :            mountains of uninitialized variable warnings."
    2987                 :             : 
    2988                 :             :            In order to maintain the status quo with regard to liveness
    2989                 :             :            and uses, we do what flow.c did and just mark any regs we
    2990                 :             :            can find in ASM_OPERANDS as used.  In global asm insns are
    2991                 :             :            scanned and regs_asm_clobbered is filled out.
    2992                 :             : 
    2993                 :             :            For all ASM_OPERANDS, we must traverse the vector of input
    2994                 :             :            operands.  We cannot just fall through here since then we
    2995                 :             :            would be confused by the ASM_INPUT rtx inside ASM_OPERANDS,
    2996                 :             :            which do not indicate traditional asms unlike their normal
    2997                 :             :            usage.  */
    2998                 :     5955825 :         if (code == ASM_OPERANDS)
    2999                 :             :           {
    3000                 :             :             int j;
    3001                 :             : 
    3002                 :     2361148 :             for (j = 0; j < ASM_OPERANDS_INPUT_LENGTH (x); j++)
    3003                 :     1137813 :               df_uses_record (collection_rec, &ASM_OPERANDS_INPUT (x, j),
    3004                 :             :                               DF_REF_REG_USE, bb, insn_info, flags);
    3005                 :             :             return;
    3006                 :             :           }
    3007                 :             :         break;
    3008                 :             :       }
    3009                 :             : 
    3010                 :   245016431 :     case VAR_LOCATION:
    3011                 :   245016431 :       df_uses_record (collection_rec,
    3012                 :             :                       &PAT_VAR_LOCATION_LOC (x),
    3013                 :             :                       DF_REF_REG_USE, bb, insn_info, flags);
    3014                 :   245016431 :       return;
    3015                 :             : 
    3016                 :    21545744 :     case PRE_DEC:
    3017                 :    21545744 :     case POST_DEC:
    3018                 :    21545744 :     case PRE_INC:
    3019                 :    21545744 :     case POST_INC:
    3020                 :    21545744 :     case PRE_MODIFY:
    3021                 :    21545744 :     case POST_MODIFY:
    3022                 :    21545744 :       gcc_assert (!DEBUG_INSN_P (insn_info->insn));
    3023                 :             :       /* Catch the def of the register being modified.  */
    3024                 :    21545744 :       df_ref_record (DF_REF_REGULAR, collection_rec, XEXP (x, 0), &XEXP (x, 0),
    3025                 :             :                      bb, insn_info,
    3026                 :             :                      DF_REF_REG_DEF,
    3027                 :             :                      flags | DF_REF_READ_WRITE | DF_REF_PRE_POST_MODIFY);
    3028                 :             : 
    3029                 :             :       /* ... Fall through to handle uses ...  */
    3030                 :             : 
    3031                 :             :     default:
    3032                 :             :       break;
    3033                 :             :     }
    3034                 :             : 
    3035                 :             :   /* Recursively scan the operands of this expression.  */
    3036                 :   851238217 :   {
    3037                 :   851238217 :     const char *fmt = GET_RTX_FORMAT (code);
    3038                 :   851238217 :     int i;
    3039                 :             : 
    3040                 :  1638505836 :     for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    3041                 :             :       {
    3042                 :  1399784785 :         if (fmt[i] == 'e')
    3043                 :             :           {
    3044                 :             :             /* Tail recursive case: save a function call level.  */
    3045                 :  1240457951 :             if (i == 0)
    3046                 :             :               {
    3047                 :   612517166 :                 loc = &XEXP (x, 0);
    3048                 :   612517166 :                 goto retry;
    3049                 :             :               }
    3050                 :   627940785 :             df_uses_record (collection_rec, &XEXP (x, i), ref_type,
    3051                 :             :                             bb, insn_info, flags);
    3052                 :             :           }
    3053                 :   159326834 :         else if (fmt[i] == 'E')
    3054                 :             :           {
    3055                 :             :             int j;
    3056                 :   295797992 :             for (j = 0; j < XVECLEN (x, i); j++)
    3057                 :   198861580 :               df_uses_record (collection_rec,
    3058                 :             :                               &XVECEXP (x, i, j), ref_type,
    3059                 :             :                               bb, insn_info, flags);
    3060                 :             :           }
    3061                 :             :       }
    3062                 :             :   }
    3063                 :             : 
    3064                 :             :   return;
    3065                 :             : }
    3066                 :             : 
    3067                 :             : 
    3068                 :             : /* For all DF_REF_CONDITIONAL defs, add a corresponding uses.  */
    3069                 :             : 
    3070                 :             : static void
    3071                 :           0 : df_get_conditional_uses (class df_collection_rec *collection_rec)
    3072                 :             : {
    3073                 :           0 :   unsigned int ix;
    3074                 :           0 :   df_ref ref;
    3075                 :             : 
    3076                 :           0 :   FOR_EACH_VEC_ELT (collection_rec->def_vec, ix, ref)
    3077                 :             :     {
    3078                 :           0 :       if (DF_REF_FLAGS_IS_SET (ref, DF_REF_CONDITIONAL))
    3079                 :             :         {
    3080                 :           0 :           df_ref use;
    3081                 :             : 
    3082                 :           0 :           use = df_ref_create_structure (DF_REF_CLASS (ref), collection_rec, DF_REF_REG (ref),
    3083                 :           0 :                                          DF_REF_LOC (ref), DF_REF_BB (ref),
    3084                 :             :                                          DF_REF_INSN_INFO (ref), DF_REF_REG_USE,
    3085                 :             :                                          DF_REF_FLAGS (ref) & ~DF_REF_CONDITIONAL);
    3086                 :           0 :           DF_REF_REGNO (use) = DF_REF_REGNO (ref);
    3087                 :             :         }
    3088                 :             :     }
    3089                 :           0 : }
    3090                 :             : 
    3091                 :             : 
    3092                 :             : /* Get call's extra defs and uses (track caller-saved registers). */
    3093                 :             : 
    3094                 :             : static void
    3095                 :    63354717 : df_get_call_refs (class df_collection_rec *collection_rec,
    3096                 :             :                   basic_block bb,
    3097                 :             :                   struct df_insn_info *insn_info,
    3098                 :             :                   int flags)
    3099                 :             : {
    3100                 :    63354717 :   rtx note;
    3101                 :    63354717 :   bool is_sibling_call;
    3102                 :    63354717 :   unsigned int i;
    3103                 :    63354717 :   HARD_REG_SET defs_generated;
    3104                 :             : 
    3105                 :    63354717 :   CLEAR_HARD_REG_SET (defs_generated);
    3106                 :    63354717 :   df_find_hard_reg_defs (PATTERN (insn_info->insn), &defs_generated);
    3107                 :    63354717 :   is_sibling_call = SIBLING_CALL_P (insn_info->insn);
    3108                 :    63354717 :   function_abi callee_abi = insn_callee_abi (insn_info->insn);
    3109                 :             : 
    3110                 :  5891988681 :   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    3111                 :             :     {
    3112                 :  5828633964 :       if (i == STACK_POINTER_REGNUM
    3113                 :  5828633964 :           && !FAKE_CALL_P (insn_info->insn))
    3114                 :             :         /* The stack ptr is used (honorarily) by a CALL insn.  */
    3115                 :    63264188 :         df_ref_record (DF_REF_BASE, collection_rec, regno_reg_rtx[i],
    3116                 :             :                        NULL, bb, insn_info, DF_REF_REG_USE,
    3117                 :             :                        DF_REF_CALL_STACK_USAGE | flags);
    3118                 :  5765369776 :       else if (global_regs[i])
    3119                 :             :         {
    3120                 :             :           /* Calls to const functions cannot access any global registers and
    3121                 :             :              calls to pure functions cannot set them.  All other calls may
    3122                 :             :              reference any of the global registers, so they are recorded as
    3123                 :             :              used. */
    3124                 :        1158 :           if (!RTL_CONST_CALL_P (insn_info->insn))
    3125                 :             :             {
    3126                 :        1158 :               df_ref_record (DF_REF_BASE, collection_rec, regno_reg_rtx[i],
    3127                 :             :                              NULL, bb, insn_info, DF_REF_REG_USE, flags);
    3128                 :        1158 :               if (!RTL_PURE_CALL_P (insn_info->insn))
    3129                 :        1045 :                 df_ref_record (DF_REF_BASE, collection_rec, regno_reg_rtx[i],
    3130                 :             :                                NULL, bb, insn_info, DF_REF_REG_DEF, flags);
    3131                 :             :             }
    3132                 :             :         }
    3133                 :  5765368618 :       else if (callee_abi.clobbers_full_reg_p (i)
    3134                 :             :                /* no clobbers for regs that are the result of the call */
    3135                 :  5170008664 :                && !TEST_HARD_REG_BIT (defs_generated, i)
    3136                 : 10909770546 :                && (!is_sibling_call
    3137                 :    98860882 :                    || !bitmap_bit_p (df->exit_block_uses, i)
    3138                 :        6923 :                    || refers_to_regno_p (i, crtl->return_rtx)))
    3139                 :  5144401928 :           df_ref_record (DF_REF_BASE, collection_rec, regno_reg_rtx[i],
    3140                 :             :                          NULL, bb, insn_info, DF_REF_REG_DEF,
    3141                 :             :                          DF_REF_MAY_CLOBBER | flags);
    3142                 :             :     }
    3143                 :             : 
    3144                 :             :   /* Record the registers used to pass arguments, and explicitly
    3145                 :             :      noted as clobbered.  */
    3146                 :   186581482 :   for (note = CALL_INSN_FUNCTION_USAGE (insn_info->insn); note;
    3147                 :   123226765 :        note = XEXP (note, 1))
    3148                 :             :     {
    3149                 :   123226765 :       if (GET_CODE (XEXP (note, 0)) == USE)
    3150                 :   114785348 :         df_uses_record (collection_rec, &XEXP (XEXP (note, 0), 0),
    3151                 :             :                         DF_REF_REG_USE, bb, insn_info, flags);
    3152                 :     8441417 :       else if (GET_CODE (XEXP (note, 0)) == CLOBBER)
    3153                 :             :         {
    3154                 :     7332003 :           if (REG_P (XEXP (XEXP (note, 0), 0)))
    3155                 :             :             {
    3156                 :     7332003 :               unsigned int regno = REGNO (XEXP (XEXP (note, 0), 0));
    3157                 :     7332003 :               if (!TEST_HARD_REG_BIT (defs_generated, regno))
    3158                 :     7331346 :                 df_defs_record (collection_rec, XEXP (note, 0), bb,
    3159                 :             :                                 insn_info, flags);
    3160                 :             :             }
    3161                 :             :           else
    3162                 :           0 :             df_uses_record (collection_rec, &XEXP (note, 0),
    3163                 :             :                             DF_REF_REG_USE, bb, insn_info, flags);
    3164                 :             :         }
    3165                 :             :     }
    3166                 :             : 
    3167                 :    63354717 :   return;
    3168                 :             : }
    3169                 :             : 
    3170                 :             : /* Collect all refs in the INSN. This function is free of any
    3171                 :             :    side-effect - it will create and return a lists of df_ref's in the
    3172                 :             :    COLLECTION_REC without putting those refs into existing ref chains
    3173                 :             :    and reg chains. */
    3174                 :             : 
    3175                 :             : static void
    3176                 :   986159029 : df_insn_refs_collect (class df_collection_rec *collection_rec,
    3177                 :             :                       basic_block bb, struct df_insn_info *insn_info)
    3178                 :             : {
    3179                 :   986159029 :   rtx note;
    3180                 :   986159029 :   bool is_cond_exec = (GET_CODE (PATTERN (insn_info->insn)) == COND_EXEC);
    3181                 :             : 
    3182                 :             :   /* Clear out the collection record.  */
    3183                 :   986159029 :   collection_rec->def_vec.truncate (0);
    3184                 :   986159029 :   collection_rec->use_vec.truncate (0);
    3185                 :   986159029 :   collection_rec->eq_use_vec.truncate (0);
    3186                 :   986159029 :   collection_rec->mw_vec.truncate (0);
    3187                 :             : 
    3188                 :             :   /* Process REG_EQUIV/REG_EQUAL notes.  */
    3189                 :  1395261461 :   for (note = REG_NOTES (insn_info->insn); note;
    3190                 :   409102432 :        note = XEXP (note, 1))
    3191                 :             :     {
    3192                 :   409102432 :       switch (REG_NOTE_KIND (note))
    3193                 :             :         {
    3194                 :    40054845 :         case REG_EQUIV:
    3195                 :    40054845 :         case REG_EQUAL:
    3196                 :    40054845 :           df_uses_record (collection_rec,
    3197                 :             :                           &XEXP (note, 0), DF_REF_REG_USE,
    3198                 :             :                           bb, insn_info, DF_REF_IN_NOTE);
    3199                 :    40054845 :           break;
    3200                 :        5814 :         case REG_NON_LOCAL_GOTO:
    3201                 :             :           /* The frame ptr is used by a non-local goto.  */
    3202                 :        5814 :           df_ref_record (DF_REF_BASE, collection_rec,
    3203                 :        5814 :                          regno_reg_rtx[FRAME_POINTER_REGNUM],
    3204                 :             :                          NULL, bb, insn_info,
    3205                 :             :                          DF_REF_REG_USE, 0);
    3206                 :        5814 :           if (!HARD_FRAME_POINTER_IS_FRAME_POINTER)
    3207                 :        5814 :             df_ref_record (DF_REF_BASE, collection_rec,
    3208                 :        5814 :                            regno_reg_rtx[HARD_FRAME_POINTER_REGNUM],
    3209                 :             :                            NULL, bb, insn_info,
    3210                 :             :                            DF_REF_REG_USE, 0);
    3211                 :        5814 :           break;
    3212                 :             :         default:
    3213                 :             :           break;
    3214                 :             :         }
    3215                 :             :     }
    3216                 :             : 
    3217                 :   986159029 :   int flags = (is_cond_exec) ? DF_REF_CONDITIONAL : 0;
    3218                 :             :   /* For CALL_INSNs, first record DF_REF_BASE register defs, as well as
    3219                 :             :      uses from CALL_INSN_FUNCTION_USAGE. */
    3220                 :   986159029 :   if (CALL_P (insn_info->insn))
    3221                 :    63354717 :     df_get_call_refs (collection_rec, bb, insn_info, flags);
    3222                 :             : 
    3223                 :             :   /* Record other defs.  These should be mostly for DF_REF_REGULAR, so
    3224                 :             :      that a qsort on the defs is unnecessary in most cases.  */
    3225                 :   986159029 :   df_defs_record (collection_rec,
    3226                 :   986159029 :                   PATTERN (insn_info->insn), bb, insn_info, 0);
    3227                 :             : 
    3228                 :             :   /* Record the register uses.  */
    3229                 :   986159029 :   df_uses_record (collection_rec,
    3230                 :   986159029 :                   &PATTERN (insn_info->insn), DF_REF_REG_USE, bb, insn_info, 0);
    3231                 :             : 
    3232                 :             :   /* DF_REF_CONDITIONAL needs corresponding USES. */
    3233                 :   986159029 :   if (is_cond_exec)
    3234                 :           0 :     df_get_conditional_uses (collection_rec);
    3235                 :             : 
    3236                 :   986159029 :   df_canonize_collection_rec (collection_rec);
    3237                 :   986159029 : }
    3238                 :             : 
    3239                 :             : /* Recompute the luids for the insns in BB.  */
    3240                 :             : 
    3241                 :             : void
    3242                 :    22480352 : df_recompute_luids (basic_block bb)
    3243                 :             : {
    3244                 :    22480352 :   rtx_insn *insn;
    3245                 :    22480352 :   int luid = 0;
    3246                 :             : 
    3247                 :    22480352 :   df_grow_insn_info ();
    3248                 :             : 
    3249                 :             :   /* Scan the block an insn at a time from beginning to end.  */
    3250                 :   269193137 :   FOR_BB_INSNS (bb, insn)
    3251                 :             :     {
    3252                 :   246712785 :       struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
    3253                 :             :       /* Inserting labels does not always trigger the incremental
    3254                 :             :          rescanning.  */
    3255                 :   246712785 :       if (!insn_info)
    3256                 :             :         {
    3257                 :     2419599 :           gcc_assert (!INSN_P (insn));
    3258                 :     2419599 :           insn_info = df_insn_create_insn_record (insn);
    3259                 :             :         }
    3260                 :             : 
    3261                 :   246712785 :       DF_INSN_INFO_LUID (insn_info) = luid;
    3262                 :   246712785 :       if (INSN_P (insn))
    3263                 :   203407728 :         luid++;
    3264                 :             :     }
    3265                 :    22480352 : }
    3266                 :             : 
    3267                 :             : 
    3268                 :             : /* Collect all artificial refs at the block level for BB and add them
    3269                 :             :    to COLLECTION_REC.  */
    3270                 :             : 
    3271                 :             : static void
    3272                 :   109876921 : df_bb_refs_collect (class df_collection_rec *collection_rec, basic_block bb)
    3273                 :             : {
    3274                 :   109876921 :   collection_rec->def_vec.truncate (0);
    3275                 :   109876921 :   collection_rec->use_vec.truncate (0);
    3276                 :   109876921 :   collection_rec->eq_use_vec.truncate (0);
    3277                 :   109876921 :   collection_rec->mw_vec.truncate (0);
    3278                 :             : 
    3279                 :   109876921 :   if (bb->index == ENTRY_BLOCK)
    3280                 :             :     {
    3281                 :     6095669 :       df_entry_block_defs_collect (collection_rec, df->entry_block_defs);
    3282                 :     6095669 :       return;
    3283                 :             :     }
    3284                 :   103781252 :   else if (bb->index == EXIT_BLOCK)
    3285                 :             :     {
    3286                 :     6095669 :       df_exit_block_uses_collect (collection_rec, df->exit_block_uses);
    3287                 :     6095669 :       return;
    3288                 :             :     }
    3289                 :             : 
    3290                 :    97685583 :   if (bb_has_eh_pred (bb))
    3291                 :             :     {
    3292                 :             :       unsigned int i;
    3293                 :             :       /* Mark the registers that will contain data for the handler.  */
    3294                 :     3413088 :       for (i = 0; ; ++i)
    3295                 :             :         {
    3296                 :     5119632 :           unsigned regno = EH_RETURN_DATA_REGNO (i);
    3297                 :     3413088 :           if (regno == INVALID_REGNUM)
    3298                 :             :             break;
    3299                 :     3413088 :           df_ref_record (DF_REF_ARTIFICIAL, collection_rec, regno_reg_rtx[regno], NULL,
    3300                 :             :                          bb, NULL, DF_REF_REG_DEF, DF_REF_AT_TOP);
    3301                 :     3413088 :         }
    3302                 :             :     }
    3303                 :             : 
    3304                 :             :   /* Add the hard_frame_pointer if this block is the target of a
    3305                 :             :      non-local goto.  */
    3306                 :    97685583 :   if (bb->flags & BB_NON_LOCAL_GOTO_TARGET)
    3307                 :        9129 :     df_ref_record (DF_REF_ARTIFICIAL, collection_rec, hard_frame_pointer_rtx, NULL,
    3308                 :             :                    bb, NULL, DF_REF_REG_DEF, DF_REF_AT_TOP);
    3309                 :             : 
    3310                 :             :   /* Add the artificial uses.  */
    3311                 :    97685583 :   if (bb->index >= NUM_FIXED_BLOCKS)
    3312                 :             :     {
    3313                 :    97685583 :       bitmap_iterator bi;
    3314                 :    97685583 :       unsigned int regno;
    3315                 :    97685583 :       bitmap au = bb_has_eh_pred (bb)
    3316                 :    97685583 :         ? &df->eh_block_artificial_uses
    3317                 :    95979039 :         : &df->regular_block_artificial_uses;
    3318                 :             : 
    3319                 :   354747072 :       EXECUTE_IF_SET_IN_BITMAP (au, 0, regno, bi)
    3320                 :             :         {
    3321                 :   257061489 :           df_ref_record (DF_REF_ARTIFICIAL, collection_rec, regno_reg_rtx[regno], NULL,
    3322                 :             :                          bb, NULL, DF_REF_REG_USE, 0);
    3323                 :             :         }
    3324                 :             :     }
    3325                 :             : 
    3326                 :    97685583 :   df_canonize_collection_rec (collection_rec);
    3327                 :             : }
    3328                 :             : 
    3329                 :             : 
    3330                 :             : /* Record all the refs within the basic block BB_INDEX and scan the instructions if SCAN_INSNS.  */
    3331                 :             : 
    3332                 :             : void
    3333                 :    39875641 : df_bb_refs_record (int bb_index, bool scan_insns)
    3334                 :             : {
    3335                 :    39875641 :   basic_block bb = BASIC_BLOCK_FOR_FN (cfun, bb_index);
    3336                 :    39875641 :   rtx_insn *insn;
    3337                 :    39875641 :   int luid = 0;
    3338                 :             : 
    3339                 :    39875641 :   if (!df)
    3340                 :     6149951 :     return;
    3341                 :             : 
    3342                 :    33725690 :   df_collection_rec collection_rec;
    3343                 :    33725690 :   df_grow_bb_info (df_scan);
    3344                 :    33725690 :   if (scan_insns)
    3345                 :             :     /* Scan the block an insn at a time from beginning to end.  */
    3346                 :   334577800 :     FOR_BB_INSNS (bb, insn)
    3347                 :             :       {
    3348                 :   306682043 :         struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
    3349                 :   306682043 :         gcc_assert (!insn_info);
    3350                 :             : 
    3351                 :   306682043 :         insn_info = df_insn_create_insn_record (insn);
    3352                 :   306682043 :         if (INSN_P (insn))
    3353                 :             :           {
    3354                 :             :             /* Record refs within INSN.  */
    3355                 :   256952657 :             DF_INSN_INFO_LUID (insn_info) = luid++;
    3356                 :   256952657 :             df_insn_refs_collect (&collection_rec, bb, DF_INSN_INFO_GET (insn));
    3357                 :   256952657 :             df_refs_add_to_chains (&collection_rec, bb, insn, copy_all);
    3358                 :             :           }
    3359                 :   306682043 :         DF_INSN_INFO_LUID (insn_info) = luid;
    3360                 :             :       }
    3361                 :             : 
    3362                 :             :   /* Other block level artificial refs */
    3363                 :    33725690 :   df_bb_refs_collect (&collection_rec, bb);
    3364                 :    33725690 :   df_refs_add_to_chains (&collection_rec, bb, NULL, copy_all);
    3365                 :             : 
    3366                 :             :   /* Now that the block has been processed, set the block as dirty so
    3367                 :             :      LR and LIVE will get it processed.  */
    3368                 :    33725690 :   df_set_bb_dirty (bb);
    3369                 :    33725690 : }
    3370                 :             : 
    3371                 :             : 
    3372                 :             : /* Get the artificial use set for a regular (i.e. non-exit/non-entry)
    3373                 :             :    block. */
    3374                 :             : 
    3375                 :             : static void
    3376                 :     9039332 : df_get_regular_block_artificial_uses (bitmap regular_block_artificial_uses)
    3377                 :             : {
    3378                 :             : #ifdef EH_USES
    3379                 :             :   unsigned int i;
    3380                 :             : #endif
    3381                 :             : 
    3382                 :     9039332 :   bitmap_clear (regular_block_artificial_uses);
    3383                 :             : 
    3384                 :     9039332 :   if (reload_completed)
    3385                 :             :     {
    3386                 :     4909823 :       if (frame_pointer_needed)
    3387                 :     1153744 :         bitmap_set_bit (regular_block_artificial_uses, HARD_FRAME_POINTER_REGNUM);
    3388                 :             :     }
    3389                 :             :   else
    3390                 :             :     /* Before reload, there are a few registers that must be forced
    3391                 :             :        live everywhere -- which might not already be the case for
    3392                 :             :        blocks within infinite loops.  */
    3393                 :             :     {
    3394                 :     4129509 :       unsigned int picreg = PIC_OFFSET_TABLE_REGNUM;
    3395                 :             : 
    3396                 :             :       /* Any reference to any pseudo before reload is a potential
    3397                 :             :          reference of the frame pointer.  */
    3398                 :     4129509 :       bitmap_set_bit (regular_block_artificial_uses, FRAME_POINTER_REGNUM);
    3399                 :             : 
    3400                 :     4129509 :       if (!HARD_FRAME_POINTER_IS_FRAME_POINTER)
    3401                 :     4129509 :         bitmap_set_bit (regular_block_artificial_uses,
    3402                 :             :                         HARD_FRAME_POINTER_REGNUM);
    3403                 :             : 
    3404                 :             :       /* Pseudos with argument area equivalences may require
    3405                 :             :          reloading via the argument pointer.  */
    3406                 :     4129509 :       if (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
    3407                 :     4129509 :           && fixed_regs[ARG_POINTER_REGNUM])
    3408                 :     4129509 :         bitmap_set_bit (regular_block_artificial_uses, ARG_POINTER_REGNUM);
    3409                 :             : 
    3410                 :             :       /* Any constant, or pseudo with constant equivalences, may
    3411                 :             :          require reloading from memory using the pic register.  */
    3412                 :     4129509 :       if (picreg != INVALID_REGNUM
    3413                 :           0 :           && fixed_regs[picreg])
    3414                 :           0 :         bitmap_set_bit (regular_block_artificial_uses, picreg);
    3415                 :             :     }
    3416                 :             :   /* The all-important stack pointer must always be live.  */
    3417                 :     9039332 :   bitmap_set_bit (regular_block_artificial_uses, STACK_POINTER_REGNUM);
    3418                 :             : 
    3419                 :             : #ifdef EH_USES
    3420                 :             :   /* EH_USES registers are used:
    3421                 :             :      1) at all insns that might throw (calls or with -fnon-call-exceptions
    3422                 :             :         trapping insns)
    3423                 :             :      2) in all EH edges
    3424                 :             :      3) to support backtraces and/or debugging, anywhere between their
    3425                 :             :         initialization and where they the saved registers are restored
    3426                 :             :         from them, including the cases where we don't reach the epilogue
    3427                 :             :         (noreturn call or infinite loop).  */
    3428                 :             :   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    3429                 :             :     if (EH_USES (i))
    3430                 :             :       bitmap_set_bit (regular_block_artificial_uses, i);
    3431                 :             : #endif
    3432                 :     9039332 : }
    3433                 :             : 
    3434                 :             : 
    3435                 :             : /* Get the artificial use set for an eh block. */
    3436                 :             : 
    3437                 :             : static void
    3438                 :     9039332 : df_get_eh_block_artificial_uses (bitmap eh_block_artificial_uses)
    3439                 :             : {
    3440                 :     9039332 :   bitmap_clear (eh_block_artificial_uses);
    3441                 :             : 
    3442                 :             :   /* The following code (down through the arg_pointer setting APPEARS
    3443                 :             :      to be necessary because there is nothing that actually
    3444                 :             :      describes what the exception handling code may actually need
    3445                 :             :      to keep alive.  */
    3446                 :     9039332 :   if (reload_completed)
    3447                 :             :     {
    3448                 :     4909823 :       if (frame_pointer_needed)
    3449                 :             :         {
    3450                 :     1153744 :           bitmap_set_bit (eh_block_artificial_uses, FRAME_POINTER_REGNUM);
    3451                 :     1153744 :           if (!HARD_FRAME_POINTER_IS_FRAME_POINTER)
    3452                 :     1153744 :             bitmap_set_bit (eh_block_artificial_uses,
    3453                 :             :                             HARD_FRAME_POINTER_REGNUM);
    3454                 :             :         }
    3455                 :     4909823 :       if (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
    3456                 :     4909823 :           && fixed_regs[ARG_POINTER_REGNUM])
    3457                 :     4909823 :         bitmap_set_bit (eh_block_artificial_uses, ARG_POINTER_REGNUM);
    3458                 :             :     }
    3459                 :     9039332 : }
    3460                 :             : 
    3461                 :             : 
    3462                 :             : 
    3463                 :             : /*----------------------------------------------------------------------------
    3464                 :             :    Specialized hard register scanning functions.
    3465                 :             : ----------------------------------------------------------------------------*/
    3466                 :             : 
    3467                 :             : 
    3468                 :             : /* Mark a register in SET.  Hard registers in large modes get all
    3469                 :             :    of their component registers set as well.  */
    3470                 :             : 
    3471                 :             : static void
    3472                 :     8441894 : df_mark_reg (rtx reg, void *vset)
    3473                 :             : {
    3474                 :     8441572 :   bitmap_set_range ((bitmap) vset, REGNO (reg), REG_NREGS (reg));
    3475                 :         322 : }
    3476                 :             : 
    3477                 :             : 
    3478                 :             : /* Set the bit for regs that are considered being defined at the entry. */
    3479                 :             : 
    3480                 :             : static void
    3481                 :    14499449 : df_get_entry_block_def_set (bitmap entry_block_defs)
    3482                 :             : {
    3483                 :    14499449 :   rtx r;
    3484                 :    14499449 :   int i;
    3485                 :             : 
    3486                 :    14499449 :   bitmap_clear (entry_block_defs);
    3487                 :             : 
    3488                 :             :   /* For separate shrink-wrapping we use LIVE to analyze which basic blocks
    3489                 :             :      need a prologue for some component to be executed before that block,
    3490                 :             :      and we do not care about any other registers.  Hence, we do not want
    3491                 :             :      any register for any component defined in the entry block, and we can
    3492                 :             :      just leave all registers undefined.  */
    3493                 :    14499449 :   if (df_scan->local_flags & DF_SCAN_EMPTY_ENTRY_EXIT)
    3494                 :             :     return;
    3495                 :             : 
    3496                 :  1348448757 :   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    3497                 :             :     {
    3498                 :  1333949308 :       if (global_regs[i])
    3499                 :        1898 :         bitmap_set_bit (entry_block_defs, i);
    3500                 :  1333949308 :       if (FUNCTION_ARG_REGNO_P (i))
    3501                 :   206089803 :         bitmap_set_bit (entry_block_defs, INCOMING_REGNO (i));
    3502                 :             :     }
    3503                 :             : 
    3504                 :             :   /* The always important stack pointer.  */
    3505                 :    14499449 :   bitmap_set_bit (entry_block_defs, STACK_POINTER_REGNUM);
    3506                 :             : 
    3507                 :             :   /* Once the prologue has been generated, all of these registers
    3508                 :             :      should just show up in the first regular block.  */
    3509                 :    14499449 :   if (targetm.have_prologue () && epilogue_completed)
    3510                 :             :     {
    3511                 :             :       /* Defs for the callee saved registers are inserted so that the
    3512                 :             :          pushes have some defining location.  */
    3513                 :   254548626 :       for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    3514                 :   251811544 :         if (!crtl->abi->clobbers_full_reg_p (i)
    3515                 :    24983713 :             && !fixed_regs[i]
    3516                 :   268564617 :             && df_regs_ever_live_p (i))
    3517                 :     4024744 :           bitmap_set_bit (entry_block_defs, i);
    3518                 :             :     }
    3519                 :             : 
    3520                 :    14499449 :   r = targetm.calls.struct_value_rtx (current_function_decl, true);
    3521                 :    14499449 :   if (r && REG_P (r))
    3522                 :           0 :     bitmap_set_bit (entry_block_defs, REGNO (r));
    3523                 :             : 
    3524                 :             :   /* If the function has an incoming STATIC_CHAIN, it has to show up
    3525                 :             :      in the entry def set.  */
    3526                 :    14499449 :   r = rtx_for_static_chain (current_function_decl, true);
    3527                 :    14499449 :   if (r && REG_P (r))
    3528                 :      203669 :     bitmap_set_bit (entry_block_defs, REGNO (r));
    3529                 :             : 
    3530                 :    14499449 :   if ((!reload_completed) || frame_pointer_needed)
    3531                 :             :     {
    3532                 :             :       /* Any reference to any pseudo before reload is a potential
    3533                 :             :          reference of the frame pointer.  */
    3534                 :     8935243 :       bitmap_set_bit (entry_block_defs, FRAME_POINTER_REGNUM);
    3535                 :             : 
    3536                 :             :       /* If they are different, also mark the hard frame pointer as live.  */
    3537                 :     8935243 :       if (!HARD_FRAME_POINTER_IS_FRAME_POINTER
    3538                 :             :           && !LOCAL_REGNO (HARD_FRAME_POINTER_REGNUM))
    3539                 :     8935243 :         bitmap_set_bit (entry_block_defs, HARD_FRAME_POINTER_REGNUM);
    3540                 :             :     }
    3541                 :             : 
    3542                 :             :   /* These registers are live everywhere.  */
    3543                 :    14499449 :   if (!reload_completed)
    3544                 :             :     {
    3545                 :             :       /* Pseudos with argument area equivalences may require
    3546                 :             :          reloading via the argument pointer.  */
    3547                 :     6935745 :       if (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
    3548                 :     6935745 :           && fixed_regs[ARG_POINTER_REGNUM])
    3549                 :     6935745 :         bitmap_set_bit (entry_block_defs, ARG_POINTER_REGNUM);
    3550                 :             : 
    3551                 :             :       /* Any constant, or pseudo with constant equivalences, may
    3552                 :             :          require reloading from memory using the pic register.  */
    3553                 :     6935745 :       unsigned int picreg = PIC_OFFSET_TABLE_REGNUM;
    3554                 :           0 :       if (picreg != INVALID_REGNUM
    3555                 :           0 :           && fixed_regs[picreg])
    3556                 :           0 :         bitmap_set_bit (entry_block_defs, picreg);
    3557                 :             :     }
    3558                 :             : 
    3559                 :             : #ifdef INCOMING_RETURN_ADDR_RTX
    3560                 :    14499449 :   if (REG_P (INCOMING_RETURN_ADDR_RTX))
    3561                 :           0 :     bitmap_set_bit (entry_block_defs, REGNO (INCOMING_RETURN_ADDR_RTX));
    3562                 :             : #endif
    3563                 :             : 
    3564                 :    14499449 :   targetm.extra_live_on_entry (entry_block_defs);
    3565                 :             : }
    3566                 :             : 
    3567                 :             : 
    3568                 :             : /* Return the (conservative) set of hard registers that are defined on
    3569                 :             :    entry to the function.
    3570                 :             :    It uses df->entry_block_defs to determine which register
    3571                 :             :    reference to include.  */
    3572                 :             : 
    3573                 :             : static void
    3574                 :    10337230 : df_entry_block_defs_collect (class df_collection_rec *collection_rec,
    3575                 :             :                              bitmap entry_block_defs)
    3576                 :             : {
    3577                 :    10337230 :   unsigned int i;
    3578                 :    10337230 :   bitmap_iterator bi;
    3579                 :             : 
    3580                 :   185784368 :   EXECUTE_IF_SET_IN_BITMAP (entry_block_defs, 0, i, bi)
    3581                 :             :     {
    3582                 :   175447138 :       df_ref_record (DF_REF_ARTIFICIAL, collection_rec, regno_reg_rtx[i], NULL,
    3583                 :   175447138 :                      ENTRY_BLOCK_PTR_FOR_FN (cfun), NULL, DF_REF_REG_DEF, 0);
    3584                 :             :     }
    3585                 :             : 
    3586                 :    10337230 :   df_canonize_collection_rec (collection_rec);
    3587                 :    10337230 : }
    3588                 :             : 
    3589                 :             : 
    3590                 :             : /* Record the (conservative) set of hard registers that are defined on
    3591                 :             :    entry to the function.  */
    3592                 :             : 
    3593                 :             : static void
    3594                 :     4241561 : df_record_entry_block_defs (bitmap entry_block_defs)
    3595                 :             : {
    3596                 :     4241561 :   class df_collection_rec collection_rec;
    3597                 :     4241561 :   df_entry_block_defs_collect (&collection_rec, entry_block_defs);
    3598                 :             : 
    3599                 :             :   /* Process bb_refs chain */
    3600                 :     4241561 :   df_refs_add_to_chains (&collection_rec,
    3601                 :     4241561 :                          BASIC_BLOCK_FOR_FN (cfun, ENTRY_BLOCK),
    3602                 :             :                          NULL,
    3603                 :             :                          copy_defs);
    3604                 :     4241561 : }
    3605                 :             : 
    3606                 :             : 
    3607                 :             : /* Update the defs in the entry block.  */
    3608                 :             : 
    3609                 :             : void
    3610                 :     5460117 : df_update_entry_block_defs (void)
    3611                 :             : {
    3612                 :     5460117 :   bool changed = false;
    3613                 :             : 
    3614                 :     5460117 :   auto_bitmap refs (&df_bitmap_obstack);
    3615                 :     5460117 :   df_get_entry_block_def_set (refs);
    3616                 :     5460117 :   gcc_assert (df->entry_block_defs);
    3617                 :     5460117 :   if (!bitmap_equal_p (df->entry_block_defs, refs))
    3618                 :             :     {
    3619                 :     1297898 :       struct df_scan_bb_info *bb_info = df_scan_get_bb_info (ENTRY_BLOCK);
    3620                 :     1297898 :       df_ref_chain_delete_du_chain (bb_info->artificial_defs);
    3621                 :     1297898 :       df_ref_chain_delete (bb_info->artificial_defs);
    3622                 :     1297898 :       bb_info->artificial_defs = NULL;
    3623                 :     1297898 :       changed = true;
    3624                 :             :     }
    3625                 :             : 
    3626                 :     1297898 :   if (changed)
    3627                 :             :     {
    3628                 :     1297898 :       df_record_entry_block_defs (refs);
    3629                 :     1297898 :       bitmap_copy (df->entry_block_defs, refs);
    3630                 :     1297898 :       df_set_bb_dirty (BASIC_BLOCK_FOR_FN (cfun, ENTRY_BLOCK));
    3631                 :             :     }
    3632                 :     5460117 : }
    3633                 :             : 
    3634                 :             : 
    3635                 :             : /* Return true if REGNO is used by the epilogue.  */
    3636                 :             : bool
    3637                 :  1446287879 : df_epilogue_uses_p (unsigned int regno)
    3638                 :             : {
    3639                 :  1446287879 :   return (EPILOGUE_USES (regno)
    3640                 :  1446287879 :           || TEST_HARD_REG_BIT (crtl->must_be_zero_on_return, regno));
    3641                 :             : }
    3642                 :             : 
    3643                 :             : /* Set the bit for regs that are considered being used at the exit. */
    3644                 :             : 
    3645                 :             : static void
    3646                 :    15720543 : df_get_exit_block_use_set (bitmap exit_block_uses)
    3647                 :             : {
    3648                 :    15720543 :   unsigned int i;
    3649                 :    15720543 :   unsigned int picreg = PIC_OFFSET_TABLE_REGNUM;
    3650                 :             : 
    3651                 :    15720543 :   bitmap_clear (exit_block_uses);
    3652                 :             : 
    3653                 :             :   /* For separate shrink-wrapping we use LIVE to analyze which basic blocks
    3654                 :             :      need an epilogue for some component to be executed after that block,
    3655                 :             :      and we do not care about any other registers.  Hence, we do not want
    3656                 :             :      any register for any component seen as used in the exit block, and we
    3657                 :             :      can just say no registers at all are used.  */
    3658                 :    15720543 :   if (df_scan->local_flags & DF_SCAN_EMPTY_ENTRY_EXIT)
    3659                 :             :     return;
    3660                 :             : 
    3661                 :             :   /* Stack pointer is always live at the exit.  */
    3662                 :    15720543 :   bitmap_set_bit (exit_block_uses, STACK_POINTER_REGNUM);
    3663                 :             : 
    3664                 :             :   /* Mark the frame pointer if needed at the end of the function.
    3665                 :             :      If we end up eliminating it, it will be removed from the live
    3666                 :             :      list of each basic block by reload.  */
    3667                 :             : 
    3668                 :    15720543 :   if ((!reload_completed) || frame_pointer_needed)
    3669                 :             :     {
    3670                 :    10156181 :       bitmap_set_bit (exit_block_uses, FRAME_POINTER_REGNUM);
    3671                 :             : 
    3672                 :             :       /* If they are different, also mark the hard frame pointer as live.  */
    3673                 :    10156181 :       if (!HARD_FRAME_POINTER_IS_FRAME_POINTER
    3674                 :             :           && !LOCAL_REGNO (HARD_FRAME_POINTER_REGNUM))
    3675                 :    10156181 :         bitmap_set_bit (exit_block_uses, HARD_FRAME_POINTER_REGNUM);
    3676                 :             :     }
    3677                 :             : 
    3678                 :             :   /* Many architectures have a GP register even without flag_pic.
    3679                 :             :      Assume the pic register is not in use, or will be handled by
    3680                 :             :      other means, if it is not fixed.  */
    3681                 :    15720543 :   if (!PIC_OFFSET_TABLE_REG_CALL_CLOBBERED
    3682                 :             :       && picreg != INVALID_REGNUM
    3683                 :           0 :       && fixed_regs[picreg])
    3684                 :           0 :     bitmap_set_bit (exit_block_uses, picreg);
    3685                 :             : 
    3686                 :             :   /* Mark all global registers, and all registers used by the
    3687                 :             :      epilogue as being live at the end of the function since they
    3688                 :             :      may be referenced by our caller.  */
    3689                 :  1462010499 :   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    3690                 :  1446289956 :     if (global_regs[i] || df_epilogue_uses_p (i))
    3691                 :        7463 :       bitmap_set_bit (exit_block_uses, i);
    3692                 :             : 
    3693                 :    15720543 :   if (targetm.have_epilogue () && epilogue_completed)
    3694                 :             :     {
    3695                 :             :       /* Mark all call-saved registers that we actually used.  */
    3696                 :   254563134 :       for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    3697                 :   251825896 :         if (df_regs_ever_live_p (i)
    3698                 :             :             && !LOCAL_REGNO (i)
    3699                 :   251825896 :             && !crtl->abi->clobbers_full_reg_p (i))
    3700                 :     6090224 :           bitmap_set_bit (exit_block_uses, i);
    3701                 :             :     }
    3702                 :             : 
    3703                 :             :   /* Mark the registers that will contain data for the handler.  */
    3704                 :    15720543 :   if (reload_completed && crtl->calls_eh_return)
    3705                 :         332 :     for (i = 0; ; ++i)
    3706                 :             :       {
    3707                 :         498 :         unsigned regno = EH_RETURN_DATA_REGNO (i);
    3708                 :         332 :         if (regno == INVALID_REGNUM)
    3709                 :             :           break;
    3710                 :         332 :         bitmap_set_bit (exit_block_uses, regno);
    3711                 :         332 :       }
    3712                 :             : 
    3713                 :             : #ifdef EH_RETURN_STACKADJ_RTX
    3714                 :    31441086 :   if ((!targetm.have_epilogue () || ! epilogue_completed)
    3715                 :    28703848 :       && crtl->calls_eh_return)
    3716                 :             :     {
    3717                 :         322 :       rtx tmp = EH_RETURN_STACKADJ_RTX;
    3718                 :         322 :       if (tmp && REG_P (tmp))
    3719                 :         322 :         df_mark_reg (tmp, exit_block_uses);
    3720                 :             :     }
    3721                 :             : #endif
    3722                 :             : 
    3723                 :             : #ifdef EH_RETURN_TAKEN_RTX
    3724                 :             :   if ((!targetm.have_epilogue () || ! epilogue_completed)
    3725                 :             :       && crtl->calls_eh_return)
    3726                 :             :     {
    3727                 :             :       rtx tmp = EH_RETURN_TAKEN_RTX;
    3728                 :             :       if (tmp && REG_P (tmp))
    3729                 :             :         df_mark_reg (tmp, exit_block_uses);
    3730                 :             :     }
    3731                 :             : #endif
    3732                 :             : 
    3733                 :    15720543 :   if ((!targetm.have_epilogue () || ! epilogue_completed)
    3734                 :             :       && crtl->calls_eh_return)
    3735                 :             :     {
    3736                 :    15720543 :       rtx tmp = EH_RETURN_HANDLER_RTX;
    3737                 :    15720543 :       if (tmp && REG_P (tmp))
    3738                 :             :         df_mark_reg (tmp, exit_block_uses);
    3739                 :             :     }
    3740                 :             : 
    3741                 :             :   /* Mark function return value.  */
    3742                 :    15720543 :   diddle_return_value (df_mark_reg, (void*) exit_block_uses);
    3743                 :             : }
    3744                 :             : 
    3745                 :             : 
    3746                 :             : /* Return the refs of hard registers that are used in the exit block.
    3747                 :             :    It uses df->exit_block_uses to determine register to include.  */
    3748                 :             : 
    3749                 :             : static void
    3750                 :    10010189 : df_exit_block_uses_collect (class df_collection_rec *collection_rec, bitmap exit_block_uses)
    3751                 :             : {
    3752                 :    10010189 :   unsigned int i;
    3753                 :    10010189 :   bitmap_iterator bi;
    3754                 :             : 
    3755                 :    39477271 :   EXECUTE_IF_SET_IN_BITMAP (exit_block_uses, 0, i, bi)
    3756                 :    29467082 :     df_ref_record (DF_REF_ARTIFICIAL, collection_rec, regno_reg_rtx[i], NULL,
    3757                 :    29467082 :                    EXIT_BLOCK_PTR_FOR_FN (cfun), NULL, DF_REF_REG_USE, 0);
    3758                 :             : 
    3759                 :             :   /* It is deliberate that this is not put in the exit block uses but
    3760                 :             :      I do not know why.  */
    3761                 :    10010189 :   if (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
    3762                 :    10010189 :       && reload_completed
    3763                 :     5880680 :       && !bitmap_bit_p (exit_block_uses, ARG_POINTER_REGNUM)
    3764                 :     5880680 :       && bb_has_eh_pred (EXIT_BLOCK_PTR_FOR_FN (cfun))
    3765                 :    10010189 :       && fixed_regs[ARG_POINTER_REGNUM])
    3766                 :           0 :     df_ref_record (DF_REF_ARTIFICIAL, collection_rec, regno_reg_rtx[ARG_POINTER_REGNUM], NULL,
    3767                 :             :                    EXIT_BLOCK_PTR_FOR_FN (cfun), NULL, DF_REF_REG_USE, 0);
    3768                 :             : 
    3769                 :    10010189 :   df_canonize_collection_rec (collection_rec);
    3770                 :    10010189 : }
    3771                 :             : 
    3772                 :             : 
    3773                 :             : /* Record the set of hard registers that are used in the exit block.
    3774                 :             :    It uses df->exit_block_uses to determine which bit to include.  */
    3775                 :             : 
    3776                 :             : static void
    3777                 :     3914520 : df_record_exit_block_uses (bitmap exit_block_uses)
    3778                 :             : {
    3779                 :     3914520 :   class df_collection_rec collection_rec;
    3780                 :     3914520 :   df_exit_block_uses_collect (&collection_rec, exit_block_uses);
    3781                 :             : 
    3782                 :             :   /* Process bb_refs chain */
    3783                 :     3914520 :   df_refs_add_to_chains (&collection_rec,
    3784                 :     3914520 :                          BASIC_BLOCK_FOR_FN (cfun, EXIT_BLOCK),
    3785                 :             :                          NULL,
    3786                 :             :                          copy_uses);
    3787                 :     3914520 : }
    3788                 :             : 
    3789                 :             : 
    3790                 :             : /* Update the uses in the exit block.  */
    3791                 :             : 
    3792                 :             : void
    3793                 :     6681211 : df_update_exit_block_uses (void)
    3794                 :             : {
    3795                 :     6681211 :   bool changed = false;
    3796                 :             : 
    3797                 :     6681211 :   auto_bitmap refs (&df_bitmap_obstack);
    3798                 :     6681211 :   df_get_exit_block_use_set (refs);
    3799                 :     6681211 :   gcc_assert (df->exit_block_uses);
    3800                 :     6681211 :   if (!bitmap_equal_p (df->exit_block_uses, refs))
    3801                 :             :     {
    3802                 :      970857 :       struct df_scan_bb_info *bb_info = df_scan_get_bb_info (EXIT_BLOCK);
    3803                 :      970857 :       df_ref_chain_delete_du_chain (bb_info->artificial_uses);
    3804                 :      970857 :       df_ref_chain_delete (bb_info->artificial_uses);
    3805                 :      970857 :       bb_info->artificial_uses = NULL;
    3806                 :      970857 :       changed = true;
    3807                 :             :     }
    3808                 :             : 
    3809                 :      970857 :   if (changed)
    3810                 :             :     {
    3811                 :      970857 :       df_record_exit_block_uses (refs);
    3812                 :      970857 :       bitmap_copy (df->exit_block_uses, refs);
    3813                 :      970857 :       df_set_bb_dirty (BASIC_BLOCK_FOR_FN (cfun, EXIT_BLOCK));
    3814                 :             :     }
    3815                 :     6681211 : }
    3816                 :             : 
    3817                 :             : static bool initialized = false;
    3818                 :             : 
    3819                 :             : 
    3820                 :             : /* Initialize some platform specific structures.  */
    3821                 :             : 
    3822                 :             : void
    3823                 :     1426767 : df_hard_reg_init (void)
    3824                 :             : {
    3825                 :     1426767 :   int i;
    3826                 :     1426767 :   static const struct {const int from, to; } eliminables[] = ELIMINABLE_REGS;
    3827                 :             : 
    3828                 :     1426767 :   if (initialized)
    3829                 :             :     return;
    3830                 :             : 
    3831                 :             :   /* Record which registers will be eliminated.  We use this in
    3832                 :             :      mark_used_regs.  */
    3833                 :     1028455 :   CLEAR_HARD_REG_SET (elim_reg_set);
    3834                 :             : 
    3835                 :     1028455 :   for (i = 0; i < (int) ARRAY_SIZE (eliminables); i++)
    3836                 :      822764 :     SET_HARD_REG_BIT (elim_reg_set, eliminables[i].from);
    3837                 :             : 
    3838                 :      205691 :   initialized = true;
    3839                 :             : }
    3840                 :             : 
    3841                 :             : /* Recompute the parts of scanning that are based on regs_ever_live
    3842                 :             :    because something changed in that array.  */
    3843                 :             : 
    3844                 :             : void
    3845                 :     5030283 : df_update_entry_exit_and_calls (void)
    3846                 :             : {
    3847                 :     5030283 :   basic_block bb;
    3848                 :             : 
    3849                 :     5030283 :   df_update_entry_block_defs ();
    3850                 :     5030283 :   df_update_exit_block_uses ();
    3851                 :             : 
    3852                 :             :   /* The call insns need to be rescanned because there may be changes
    3853                 :             :      in the set of registers clobbered across the call.  */
    3854                 :    56807392 :   FOR_EACH_BB_FN (bb, cfun)
    3855                 :             :     {
    3856                 :    51777109 :       rtx_insn *insn;
    3857                 :   616681485 :       FOR_BB_INSNS (bb, insn)
    3858                 :             :         {
    3859                 :   564904376 :           if (INSN_P (insn) && CALL_P (insn))
    3860                 :    22717923 :             df_insn_rescan (insn);
    3861                 :             :         }
    3862                 :             :     }
    3863                 :     5030283 : }
    3864                 :             : 
    3865                 :             : 
    3866                 :             : /* Return true if hard REG is actually used in the some instruction.
    3867                 :             :    There are a fair number of conditions that affect the setting of
    3868                 :             :    this array.  See the comment in df.h for df->hard_regs_live_count
    3869                 :             :    for the conditions that this array is set. */
    3870                 :             : 
    3871                 :             : bool
    3872                 :  3406746937 : df_hard_reg_used_p (unsigned int reg)
    3873                 :             : {
    3874                 :  3406746937 :   return df->hard_regs_live_count[reg] != 0;
    3875                 :             : }
    3876                 :             : 
    3877                 :             : 
    3878                 :             : /* A count of the number of times REG is actually used in the some
    3879                 :             :    instruction.  There are a fair number of conditions that affect the
    3880                 :             :    setting of this array.  See the comment in df.h for
    3881                 :             :    df->hard_regs_live_count for the conditions that this array is
    3882                 :             :    set. */
    3883                 :             : 
    3884                 :             : 
    3885                 :             : unsigned int
    3886                 :           0 : df_hard_reg_used_count (unsigned int reg)
    3887                 :             : {
    3888                 :           0 :   return df->hard_regs_live_count[reg];
    3889                 :             : }
    3890                 :             : 
    3891                 :             : 
    3892                 :             : /* Get the value of regs_ever_live[REGNO].  */
    3893                 :             : 
    3894                 :             : bool
    3895                 :   677570729 : df_regs_ever_live_p (unsigned int regno)
    3896                 :             : {
    3897                 :   677570729 :   return regs_ever_live[regno];
    3898                 :             : }
    3899                 :             : 
    3900                 :             : /* Set regs_ever_live[REGNO] to VALUE.  If this cause regs_ever_live
    3901                 :             :    to change, schedule that change for the next update.  */
    3902                 :             : 
    3903                 :             : void
    3904                 :    98598646 : df_set_regs_ever_live (unsigned int regno, bool value)
    3905                 :             : {
    3906                 :    98598646 :   if (regs_ever_live[regno] == value)
    3907                 :             :     return;
    3908                 :             : 
    3909                 :     3557669 :   regs_ever_live[regno] = value;
    3910                 :     3557669 :   if (df)
    3911                 :     3557669 :     df->redo_entry_and_exit = true;
    3912                 :             : }
    3913                 :             : 
    3914                 :             : 
    3915                 :             : /* Compute "regs_ever_live" information from the underlying df
    3916                 :             :    information.  Set the vector to all false if RESET.  */
    3917                 :             : 
    3918                 :             : void
    3919                 :    39314336 : df_compute_regs_ever_live (bool reset)
    3920                 :             : {
    3921                 :    39314336 :   unsigned int i;
    3922                 :    39314336 :   bool changed = df->redo_entry_and_exit;
    3923                 :             : 
    3924                 :    39314336 :   if (reset)
    3925                 :     2443315 :     memset (regs_ever_live, 0, sizeof (regs_ever_live));
    3926                 :             : 
    3927                 :  3656233248 :   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    3928                 :  3616918912 :     if ((!regs_ever_live[i]) && df_hard_reg_used_p (i))
    3929                 :             :       {
    3930                 :    11998226 :         regs_ever_live[i] = true;
    3931                 :    11998226 :         changed = true;
    3932                 :             :       }
    3933                 :    39314336 :   if (changed)
    3934                 :     3162756 :     df_update_entry_exit_and_calls ();
    3935                 :    39314336 :   df->redo_entry_and_exit = false;
    3936                 :    39314336 : }
    3937                 :             : 
    3938                 :             : 
    3939                 :             : /*----------------------------------------------------------------------------
    3940                 :             :   Dataflow ref information verification functions.
    3941                 :             : 
    3942                 :             :   df_reg_chain_mark (refs, regno, is_def, is_eq_use)
    3943                 :             :   df_reg_chain_verify_unmarked (refs)
    3944                 :             :   df_refs_verify (vec<stack, va_df_ref>, ref*, bool)
    3945                 :             :   df_mws_verify (mw*, mw*, bool)
    3946                 :             :   df_insn_refs_verify (collection_rec, bb, insn, bool)
    3947                 :             :   df_bb_refs_verify (bb, refs, bool)
    3948                 :             :   df_bb_verify (bb)
    3949                 :             :   df_exit_block_bitmap_verify (bool)
    3950                 :             :   df_entry_block_bitmap_verify (bool)
    3951                 :             :   df_scan_verify ()
    3952                 :             : ----------------------------------------------------------------------------*/
    3953                 :             : 
    3954                 :             : 
    3955                 :             : /* Mark all refs in the reg chain.  Verify that all of the registers
    3956                 :             : are in the correct chain.  */
    3957                 :             : 
    3958                 :             : static unsigned int
    3959                 :  2615315448 : df_reg_chain_mark (df_ref refs, unsigned int regno,
    3960                 :             :                    bool is_def, bool is_eq_use)
    3961                 :             : {
    3962                 :  2615315448 :   unsigned int count = 0;
    3963                 :  2615315448 :   df_ref ref;
    3964                 :  5975059193 :   for (ref = refs; ref; ref = DF_REF_NEXT_REG (ref))
    3965                 :             :     {
    3966                 :  3359743745 :       gcc_assert (!DF_REF_IS_REG_MARKED (ref));
    3967                 :             : 
    3968                 :             :       /* If there are no def-use or use-def chains, make sure that all
    3969                 :             :          of the chains are clear.  */
    3970                 :  3359743745 :       if (!df_chain)
    3971                 :  3091207250 :         gcc_assert (!DF_REF_CHAIN (ref));
    3972                 :             : 
    3973                 :             :       /* Check to make sure the ref is in the correct chain.  */
    3974                 :  3359743745 :       gcc_assert (DF_REF_REGNO (ref) == regno);
    3975                 :  3359743745 :       if (is_def)
    3976                 :  2666156813 :         gcc_assert (DF_REF_REG_DEF_P (ref));
    3977                 :             :       else
    3978                 :   693586932 :         gcc_assert (!DF_REF_REG_DEF_P (ref));
    3979                 :             : 
    3980                 :  3359743745 :       if (is_eq_use)
    3981                 :    17359169 :         gcc_assert ((DF_REF_FLAGS (ref) & DF_REF_IN_NOTE));
    3982                 :             :       else
    3983                 :  3342384576 :         gcc_assert ((DF_REF_FLAGS (ref) & DF_REF_IN_NOTE) == 0);
    3984                 :             : 
    3985                 :  3359743745 :       if (DF_REF_NEXT_REG (ref))
    3986                 :  2792927106 :         gcc_assert (DF_REF_PREV_REG (DF_REF_NEXT_REG (ref)) == ref);
    3987                 :  3359743745 :       count++;
    3988                 :  3359743745 :       DF_REF_REG_MARK (ref);
    3989                 :             :     }
    3990                 :  2615315448 :   return count;
    3991                 :             : }
    3992                 :             : 
    3993                 :             : 
    3994                 :             : /* Verify that all of the registers in the chain are unmarked.  */
    3995                 :             : 
    3996                 :             : static void
    3997                 :  2615315448 : df_reg_chain_verify_unmarked (df_ref refs)
    3998                 :             : {
    3999                 :  2615315448 :   df_ref ref;
    4000                 :  5975059193 :   for (ref = refs; ref; ref = DF_REF_NEXT_REG (ref))
    4001                 :  3359743745 :     gcc_assert (!DF_REF_IS_REG_MARKED (ref));
    4002                 :  2615315448 : }
    4003                 :             : 
    4004                 :             : 
    4005                 :             : /* Verify that NEW_REC and OLD_REC have exactly the same members. */
    4006                 :             : 
    4007                 :             : static bool
    4008                 :  2185564045 : df_refs_verify (const vec<df_ref, va_heap> *new_rec, df_ref old_rec,
    4009                 :             :                 bool abort_if_fail)
    4010                 :             : {
    4011                 :  2185564045 :   unsigned int ix;
    4012                 :  2185564045 :   df_ref new_ref;
    4013                 :             : 
    4014                 :  7582531974 :   FOR_EACH_VEC_ELT (*new_rec, ix, new_ref)
    4015                 :             :     {
    4016                 :  5438375018 :       if (old_rec == NULL || !df_ref_equal_p (new_ref, old_rec))
    4017                 :             :         {
    4018                 :    41407089 :           if (abort_if_fail)
    4019                 :           0 :             gcc_assert (0);
    4020                 :             :           else
    4021                 :             :             return false;
    4022                 :             :         }
    4023                 :             : 
    4024                 :             :       /* Abort if fail is called from the function level verifier.  If
    4025                 :             :          that is the context, mark this reg as being seem.  */
    4026                 :  5396967929 :       if (abort_if_fail)
    4027                 :             :         {
    4028                 :  3359743745 :           gcc_assert (DF_REF_IS_REG_MARKED (old_rec));
    4029                 :  3359743745 :           DF_REF_REG_UNMARK (old_rec);
    4030                 :             :         }
    4031                 :             : 
    4032                 :  5396967929 :       old_rec = DF_REF_NEXT_LOC (old_rec);
    4033                 :             :     }
    4034                 :             : 
    4035                 :  2144156956 :   if (abort_if_fail)
    4036                 :  1931070664 :     gcc_assert (old_rec == NULL);
    4037                 :             :   else
    4038                 :   213086292 :     return old_rec == NULL;
    4039                 :             :   return false;
    4040                 :             : }
    4041                 :             : 
    4042                 :             : 
    4043                 :             : /* Verify that NEW_REC and OLD_REC have exactly the same members. */
    4044                 :             : 
    4045                 :             : static bool
    4046                 :   650140612 : df_mws_verify (const vec<df_mw_hardreg *, va_heap> *new_rec,
    4047                 :             :                struct df_mw_hardreg *old_rec,
    4048                 :             :                bool abort_if_fail)
    4049                 :             : {
    4050                 :   650140612 :   unsigned int ix;
    4051                 :   650140612 :   struct df_mw_hardreg *new_reg;
    4052                 :             : 
    4053                 :   654854311 :   FOR_EACH_VEC_ELT (*new_rec, ix, new_reg)
    4054                 :             :     {
    4055                 :     4715442 :       if (old_rec == NULL || !df_mw_equal_p (new_reg, old_rec))
    4056                 :             :         {
    4057                 :        1743 :           if (abort_if_fail)
    4058                 :           0 :             gcc_assert (0);
    4059                 :             :           else
    4060                 :             :             return false;
    4061                 :             :         }
    4062                 :     4713699 :       old_rec = DF_MWS_NEXT (old_rec);
    4063                 :             :     }
    4064                 :             : 
    4065                 :   650138869 :   if (abort_if_fail)
    4066                 :   592922734 :     gcc_assert (old_rec == NULL);
    4067                 :             :   else
    4068                 :    57216135 :     return old_rec == NULL;
    4069                 :             :   return false;
    4070                 :             : }
    4071                 :             : 
    4072                 :             : 
    4073                 :             : /* Return true if the existing insn refs information is complete and
    4074                 :             :    correct. Otherwise (i.e. if there's any missing or extra refs),
    4075                 :             :    return the correct df_ref chain in REFS_RETURN.
    4076                 :             : 
    4077                 :             :    If ABORT_IF_FAIL, leave the refs that are verified (already in the
    4078                 :             :    ref chain) as DF_REF_MARKED(). If it's false, then it's a per-insn
    4079                 :             :    verification mode instead of the whole function, so unmark
    4080                 :             :    everything.
    4081                 :             : 
    4082                 :             :    If ABORT_IF_FAIL is set, this function never returns false.  */
    4083                 :             : 
    4084                 :             : static bool
    4085                 :   694588641 : df_insn_refs_verify (class df_collection_rec *collection_rec,
    4086                 :             :                      basic_block bb,
    4087                 :             :                      rtx_insn *insn,
    4088                 :             :                      bool abort_if_fail)
    4089                 :             : {
    4090                 :   694588641 :   bool ret1, ret2, ret3;
    4091                 :   694588641 :   unsigned int uid = INSN_UID (insn);
    4092                 :   694588641 :   struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
    4093                 :             : 
    4094                 :   694588641 :   df_insn_refs_collect (collection_rec, bb, insn_info);
    4095                 :             : 
    4096                 :             :   /* Unfortunately we cannot opt out early if one of these is not
    4097                 :             :      right and abort_if_fail is set because the marks will not get cleared.  */
    4098                 :   694588641 :   ret1 = df_refs_verify (&collection_rec->def_vec, DF_INSN_UID_DEFS (uid),
    4099                 :             :                          abort_if_fail);
    4100                 :   694588641 :   if (!ret1 && !abort_if_fail)
    4101                 :             :     return false;
    4102                 :   688364735 :   ret2 = df_refs_verify (&collection_rec->use_vec, DF_INSN_UID_USES (uid),
    4103                 :             :                          abort_if_fail);
    4104                 :   688364735 :   if (!ret2 && !abort_if_fail)
    4105                 :             :     return false;
    4106                 :   650308207 :   ret3 = df_refs_verify (&collection_rec->eq_use_vec, DF_INSN_UID_EQ_USES (uid),
    4107                 :             :                          abort_if_fail);
    4108                 :   650308207 :   if (!ret3 && !abort_if_fail)
    4109                 :             :     return false;
    4110                 :   650140612 :   if (! df_mws_verify (&collection_rec->mw_vec, DF_INSN_UID_MWS (uid),
    4111                 :             :                        abort_if_fail))
    4112                 :             :     return false;
    4113                 :    57216135 :   return (ret1 && ret2 && ret3);
    4114                 :             : }
    4115                 :             : 
    4116                 :             : 
    4117                 :             : /* Return true if all refs in the basic block are correct and complete.
    4118                 :             :    Due to df_ref_chain_verify, it will cause all refs
    4119                 :             :    that are verified to have DF_REF_MARK bit set.  */
    4120                 :             : 
    4121                 :             : static bool
    4122                 :    76151231 : df_bb_verify (basic_block bb)
    4123                 :             : {
    4124                 :    76151231 :   rtx_insn *insn;
    4125                 :    76151231 :   struct df_scan_bb_info *bb_info = df_scan_get_bb_info (bb->index);
    4126                 :    76151231 :   class df_collection_rec collection_rec;
    4127                 :             : 
    4128                 :    76151231 :   gcc_assert (bb_info);
    4129                 :             : 
    4130                 :             :   /* Scan the block, one insn at a time, from beginning to end.  */
    4131                 :   790893899 :   FOR_BB_INSNS_REVERSE (bb, insn)
    4132                 :             :     {
    4133                 :   714742668 :       if (!INSN_P (insn))
    4134                 :   121819934 :         continue;
    4135                 :   592922734 :       df_insn_refs_verify (&collection_rec, bb, insn, true);
    4136                 :   592922734 :       df_free_collection_rec (&collection_rec);
    4137                 :             :     }
    4138                 :             : 
    4139                 :             :   /* Do the artificial defs and uses.  */
    4140                 :    76151231 :   df_bb_refs_collect (&collection_rec, bb);
    4141                 :   152302462 :   df_refs_verify (&collection_rec.def_vec, df_get_artificial_defs (bb->index), true);
    4142                 :    76151231 :   df_refs_verify (&collection_rec.use_vec, df_get_artificial_uses (bb->index), true);
    4143                 :    76151231 :   df_free_collection_rec (&collection_rec);
    4144                 :             : 
    4145                 :   152302462 :   return true;
    4146                 :    76151231 : }
    4147                 :             : 
    4148                 :             : 
    4149                 :             : /* Returns true if the entry block has correct and complete df_ref set.
    4150                 :             :    If not it either aborts if ABORT_IF_FAIL is true or returns false.  */
    4151                 :             : 
    4152                 :             : static bool
    4153                 :     6095669 : df_entry_block_bitmap_verify (bool abort_if_fail)
    4154                 :             : {
    4155                 :     6095669 :   bool is_eq;
    4156                 :             : 
    4157                 :     6095669 :   auto_bitmap entry_block_defs (&df_bitmap_obstack);
    4158                 :     6095669 :   df_get_entry_block_def_set (entry_block_defs);
    4159                 :             : 
    4160                 :     6095669 :   is_eq = bitmap_equal_p (entry_block_defs, df->entry_block_defs);
    4161                 :             : 
    4162                 :     6095669 :   if (!is_eq && abort_if_fail)
    4163                 :             :     {
    4164                 :           0 :       fprintf (stderr, "entry_block_defs = ");
    4165                 :           0 :       df_print_regset (stderr, entry_block_defs);
    4166                 :           0 :       fprintf (stderr, "df->entry_block_defs = ");
    4167                 :           0 :       df_print_regset (stderr, df->entry_block_defs);
    4168                 :           0 :       gcc_assert (0);
    4169                 :             :     }
    4170                 :             : 
    4171                 :     6095669 :   return is_eq;
    4172                 :     6095669 : }
    4173                 :             : 
    4174                 :             : 
    4175                 :             : /* Returns true if the exit block has correct and complete df_ref set.
    4176                 :             :    If not it either aborts if ABORT_IF_FAIL is true or returns false. */
    4177                 :             : 
    4178                 :             : static bool
    4179                 :     6095669 : df_exit_block_bitmap_verify (bool abort_if_fail)
    4180                 :             : {
    4181                 :     6095669 :   bool is_eq;
    4182                 :             : 
    4183                 :     6095669 :   auto_bitmap exit_block_uses (&df_bitmap_obstack);
    4184                 :     6095669 :   df_get_exit_block_use_set (exit_block_uses);
    4185                 :             : 
    4186                 :     6095669 :   is_eq = bitmap_equal_p (exit_block_uses, df->exit_block_uses);
    4187                 :             : 
    4188                 :     6095669 :   if (!is_eq && abort_if_fail)
    4189                 :             :     {
    4190                 :           0 :       fprintf (stderr, "exit_block_uses = ");
    4191                 :           0 :       df_print_regset (stderr, exit_block_uses);
    4192                 :           0 :       fprintf (stderr, "df->exit_block_uses = ");
    4193                 :           0 :       df_print_regset (stderr, df->exit_block_uses);
    4194                 :           0 :       gcc_assert (0);
    4195                 :             :     }
    4196                 :             : 
    4197                 :     6095669 :   return is_eq;
    4198                 :     6095669 : }
    4199                 :             : 
    4200                 :             : 
    4201                 :             : /* Return true if df_ref information for all insns in all blocks are
    4202                 :             :    correct and complete.  */
    4203                 :             : 
    4204                 :             : void
    4205                 :     6095669 : df_scan_verify (void)
    4206                 :             : {
    4207                 :     6095669 :   unsigned int i;
    4208                 :     6095669 :   basic_block bb;
    4209                 :             : 
    4210                 :     6095669 :   if (!df)
    4211                 :           0 :     return;
    4212                 :             : 
    4213                 :             :   /* Verification is a 4 step process. */
    4214                 :             : 
    4215                 :             :   /* (1) All of the refs are marked by going through the reg chains.  */
    4216                 :   877867485 :   for (i = 0; i < DF_REG_SIZE (df); i++)
    4217                 :             :     {
    4218                 :   871771816 :       gcc_assert (df_reg_chain_mark (DF_REG_DEF_CHAIN (i), i, true, false)
    4219                 :             :                   == DF_REG_DEF_COUNT (i));
    4220                 :   871771816 :       gcc_assert (df_reg_chain_mark (DF_REG_USE_CHAIN (i), i, false, false)
    4221                 :             :                   == DF_REG_USE_COUNT (i));
    4222                 :   871771816 :       gcc_assert (df_reg_chain_mark (DF_REG_EQ_USE_CHAIN (i), i, false, true)
    4223                 :             :                   == DF_REG_EQ_USE_COUNT (i));
    4224                 :             :     }
    4225                 :             : 
    4226                 :             :   /* (2) There are various bitmaps whose value may change over the
    4227                 :             :      course of the compilation.  This step recomputes them to make
    4228                 :             :      sure that they have not slipped out of date.  */
    4229                 :     6095669 :   auto_bitmap regular_block_artificial_uses (&df_bitmap_obstack);
    4230                 :     6095669 :   auto_bitmap eh_block_artificial_uses (&df_bitmap_obstack);
    4231                 :             : 
    4232                 :     6095669 :   df_get_regular_block_artificial_uses (regular_block_artificial_uses);
    4233                 :     6095669 :   df_get_eh_block_artificial_uses (eh_block_artificial_uses);
    4234                 :             : 
    4235                 :     6095669 :   bitmap_ior_into (eh_block_artificial_uses,
    4236                 :             :                    regular_block_artificial_uses);
    4237                 :             : 
    4238                 :             :   /* Check artificial_uses bitmaps didn't change. */
    4239                 :     6095669 :   gcc_assert (bitmap_equal_p (regular_block_artificial_uses,
    4240                 :             :                               &df->regular_block_artificial_uses));
    4241                 :     6095669 :   gcc_assert (bitmap_equal_p (eh_block_artificial_uses,
    4242                 :             :                               &df->eh_block_artificial_uses));
    4243                 :             : 
    4244                 :             :   /* Verify entry block and exit block. These only verify the bitmaps,
    4245                 :             :      the refs are verified in df_bb_verify.  */
    4246                 :     6095669 :   df_entry_block_bitmap_verify (true);
    4247                 :     6095669 :   df_exit_block_bitmap_verify (true);
    4248                 :             : 
    4249                 :             :   /* (3) All of the insns in all of the blocks are traversed and the
    4250                 :             :      marks are cleared both in the artificial refs attached to the
    4251                 :             :      blocks and the real refs inside the insns.  It is a failure to
    4252                 :             :      clear a mark that has not been set as this means that the ref in
    4253                 :             :      the block or insn was not in the reg chain.  */
    4254                 :             : 
    4255                 :    82246900 :   FOR_ALL_BB_FN (bb, cfun)
    4256                 :    76151231 :     df_bb_verify (bb);
    4257                 :             : 
    4258                 :             :   /* (4) See if all reg chains are traversed a second time.  This time
    4259                 :             :      a check is made that the marks are clear. A set mark would be a
    4260                 :             :      from a reg that is not in any insn or basic block.  */
    4261                 :             : 
    4262                 :   877867485 :   for (i = 0; i < DF_REG_SIZE (df); i++)
    4263                 :             :     {
    4264                 :   871771816 :       df_reg_chain_verify_unmarked (DF_REG_DEF_CHAIN (i));
    4265                 :   871771816 :       df_reg_chain_verify_unmarked (DF_REG_USE_CHAIN (i));
    4266                 :   871771816 :       df_reg_chain_verify_unmarked (DF_REG_EQ_USE_CHAIN (i));
    4267                 :             :     }
    4268                 :     6095669 : }
        

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.