LCOV - code coverage report
Current view: top level - gcc - df-problems.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 76.2 % 1892 1441
Test Date: 2024-04-20 14:03:02 Functions: 75.3 % 146 110
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Standard problems for dataflow support routines.
       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 "df.h"
      31                 :             : #include "memmodel.h"
      32                 :             : #include "tm_p.h"
      33                 :             : #include "insn-config.h"
      34                 :             : #include "cfganal.h"
      35                 :             : #include "dce.h"
      36                 :             : #include "valtrack.h"
      37                 :             : #include "dumpfile.h"
      38                 :             : #include "rtl-iter.h"
      39                 :             : #include "regs.h"
      40                 :             : #include "function-abi.h"
      41                 :             : 
      42                 :             : /* Note that turning REG_DEAD_DEBUGGING on will cause
      43                 :             :    gcc.c-torture/unsorted/dump-noaddr.c to fail because it prints
      44                 :             :    addresses in the dumps.  */
      45                 :             : #define REG_DEAD_DEBUGGING 0
      46                 :             : 
      47                 :             : #define DF_SPARSE_THRESHOLD 32
      48                 :             : 
      49                 :             : static bitmap_head seen_in_block;
      50                 :             : static bitmap_head seen_in_insn;
      51                 :             : 
      52                 :             : /*----------------------------------------------------------------------------
      53                 :             :    Utility functions.
      54                 :             : ----------------------------------------------------------------------------*/
      55                 :             : 
      56                 :             : /* Generic versions to get the void* version of the block info.  Only
      57                 :             :    used inside the problem instance vectors.  */
      58                 :             : 
      59                 :             : /* Dump a def-use or use-def chain for REF to FILE.  */
      60                 :             : 
      61                 :             : void
      62                 :       26831 : df_chain_dump (struct df_link *link, FILE *file)
      63                 :             : {
      64                 :       26831 :   fprintf (file, "{ ");
      65                 :       56797 :   for (; link; link = link->next)
      66                 :             :     {
      67                 :        4666 :       fprintf (file, "%c%d(bb %d insn %d) ",
      68                 :        3135 :                DF_REF_REG_DEF_P (link->ref)
      69                 :           0 :                ? 'd'
      70                 :           0 :                : (DF_REF_FLAGS (link->ref) & DF_REF_IN_NOTE) ? 'e' : 'u',
      71                 :             :                DF_REF_ID (link->ref),
      72                 :        3135 :                DF_REF_BBNO (link->ref),
      73                 :        3135 :                DF_REF_IS_ARTIFICIAL (link->ref)
      74                 :        1531 :                ? -1 : DF_REF_INSN_UID (link->ref));
      75                 :             :     }
      76                 :       26831 :   fprintf (file, "}");
      77                 :       26831 : }
      78                 :             : 
      79                 :             : 
      80                 :             : /* Print some basic block info as part of df_dump.  */
      81                 :             : 
      82                 :             : void
      83                 :        3741 : df_print_bb_index (basic_block bb, FILE *file)
      84                 :             : {
      85                 :        3741 :   edge e;
      86                 :        3741 :   edge_iterator ei;
      87                 :             : 
      88                 :        3741 :   fprintf (file, "\n( ");
      89                 :        8450 :     FOR_EACH_EDGE (e, ei, bb->preds)
      90                 :             :     {
      91                 :        4709 :       basic_block pred = e->src;
      92                 :        9418 :       fprintf (file, "%d%s ", pred->index, e->flags & EDGE_EH ? "(EH)" : "");
      93                 :             :     }
      94                 :        3741 :   fprintf (file, ")->[%d]->( ", bb->index);
      95                 :        8450 :   FOR_EACH_EDGE (e, ei, bb->succs)
      96                 :             :     {
      97                 :        4709 :       basic_block succ = e->dest;
      98                 :        9418 :       fprintf (file, "%d%s ", succ->index, e->flags & EDGE_EH ? "(EH)" : "");
      99                 :             :     }
     100                 :        3741 :   fprintf (file, ")\n");
     101                 :        3741 : }
     102                 :             : 
     103                 :             : 
     104                 :             : /*----------------------------------------------------------------------------
     105                 :             :    REACHING DEFINITIONS
     106                 :             : 
     107                 :             :    Find the locations in the function where each definition site for a
     108                 :             :    pseudo reaches.  In and out bitvectors are built for each basic
     109                 :             :    block.  The id field in the ref is used to index into these sets.
     110                 :             :    See df.h for details.
     111                 :             : 
     112                 :             :    If the DF_RD_PRUNE_DEAD_DEFS changeable flag is set, only DEFs reaching
     113                 :             :    existing uses are included in the global reaching DEFs set, or in other
     114                 :             :    words only DEFs that are still live.  This is a kind of pruned version
     115                 :             :    of the traditional reaching definitions problem that is much less
     116                 :             :    complex to compute and produces enough information to compute UD-chains.
     117                 :             :    In this context, live must be interpreted in the DF_LR sense: Uses that
     118                 :             :    are upward exposed but maybe not initialized on all paths through the
     119                 :             :    CFG.  For a USE that is not reached by a DEF on all paths, we still want
     120                 :             :    to make those DEFs that do reach the USE visible, and pruning based on
     121                 :             :    DF_LIVE would make that impossible.
     122                 :             :    ----------------------------------------------------------------------------*/
     123                 :             : 
     124                 :             : /* This problem plays a large number of games for the sake of
     125                 :             :    efficiency.
     126                 :             : 
     127                 :             :    1) The order of the bits in the bitvectors.  After the scanning
     128                 :             :    phase, all of the defs are sorted.  All of the defs for the reg 0
     129                 :             :    are first, followed by all defs for reg 1 and so on.
     130                 :             : 
     131                 :             :    2) There are two kill sets, one if the number of defs is less or
     132                 :             :    equal to DF_SPARSE_THRESHOLD and another if the number of defs is
     133                 :             :    greater.
     134                 :             : 
     135                 :             :    <= : Data is built directly in the kill set.
     136                 :             : 
     137                 :             :    > : One level of indirection is used to keep from generating long
     138                 :             :    strings of 1 bits in the kill sets.  Bitvectors that are indexed
     139                 :             :    by the regnum are used to represent that there is a killing def
     140                 :             :    for the register.  The confluence and transfer functions use
     141                 :             :    these along with the bitmap_clear_range call to remove ranges of
     142                 :             :    bits without actually generating a knockout vector.
     143                 :             : 
     144                 :             :    The kill and sparse_kill and the dense_invalidated_by_eh and
     145                 :             :    sparse_invalidated_by_eh both play this game.  */
     146                 :             : 
     147                 :             : /* Private data used to compute the solution for this problem.  These
     148                 :             :    data structures are not accessible outside of this module.  */
     149                 :             : class df_rd_problem_data
     150                 :             : {
     151                 :             : public:
     152                 :             :   /* The set of defs to regs invalidated by EH edges.  */
     153                 :             :   bitmap_head sparse_invalidated_by_eh;
     154                 :             :   bitmap_head dense_invalidated_by_eh;
     155                 :             :   /* An obstack for the bitmaps we need for this problem.  */
     156                 :             :   bitmap_obstack rd_bitmaps;
     157                 :             : };
     158                 :             : 
     159                 :             : 
     160                 :             : /* Free basic block info.  */
     161                 :             : 
     162                 :             : static void
     163                 :     2899499 : df_rd_free_bb_info (basic_block bb ATTRIBUTE_UNUSED,
     164                 :             :                     void *vbb_info)
     165                 :             : {
     166                 :     2899499 :   class df_rd_bb_info *bb_info = (class df_rd_bb_info *) vbb_info;
     167                 :     2899499 :   if (bb_info)
     168                 :             :     {
     169                 :     2899499 :       bitmap_clear (&bb_info->kill);
     170                 :     2899499 :       bitmap_clear (&bb_info->sparse_kill);
     171                 :     2899499 :       bitmap_clear (&bb_info->gen);
     172                 :     2899499 :       bitmap_clear (&bb_info->in);
     173                 :     2899499 :       bitmap_clear (&bb_info->out);
     174                 :             :     }
     175                 :     2899499 : }
     176                 :             : 
     177                 :             : 
     178                 :             : /* Allocate or reset bitmaps for DF_RD blocks. The solution bits are
     179                 :             :    not touched unless the block is new.  */
     180                 :             : 
     181                 :             : static void
     182                 :     5566829 : df_rd_alloc (bitmap all_blocks)
     183                 :             : {
     184                 :     5566829 :   unsigned int bb_index;
     185                 :     5566829 :   bitmap_iterator bi;
     186                 :     5566829 :   class df_rd_problem_data *problem_data;
     187                 :             : 
     188                 :     5566829 :   if (df_rd->problem_data)
     189                 :             :     {
     190                 :      754018 :       problem_data = (class df_rd_problem_data *) df_rd->problem_data;
     191                 :      754018 :       bitmap_clear (&problem_data->sparse_invalidated_by_eh);
     192                 :      754018 :       bitmap_clear (&problem_data->dense_invalidated_by_eh);
     193                 :             :     }
     194                 :             :   else
     195                 :             :     {
     196                 :     4812811 :       problem_data = XNEW (class df_rd_problem_data);
     197                 :     4812811 :       df_rd->problem_data = problem_data;
     198                 :             : 
     199                 :     4812811 :       bitmap_obstack_initialize (&problem_data->rd_bitmaps);
     200                 :     4812811 :       bitmap_initialize (&problem_data->sparse_invalidated_by_eh,
     201                 :             :                          &problem_data->rd_bitmaps);
     202                 :     4812811 :       bitmap_initialize (&problem_data->dense_invalidated_by_eh,
     203                 :             :                          &problem_data->rd_bitmaps);
     204                 :             :     }
     205                 :             : 
     206                 :     5566829 :   df_grow_bb_info (df_rd);
     207                 :             : 
     208                 :             :   /* Because of the clustering of all use sites for the same pseudo,
     209                 :             :      we have to process all of the blocks before doing the analysis.  */
     210                 :             : 
     211                 :    66041106 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
     212                 :             :     {
     213                 :    60474277 :       class df_rd_bb_info *bb_info = df_rd_get_bb_info (bb_index);
     214                 :             :       
     215                 :             :       /* When bitmaps are already initialized, just clear them.  */
     216                 :    60474277 :       if (bb_info->kill.obstack)
     217                 :             :         {
     218                 :     1313142 :           bitmap_clear (&bb_info->kill);
     219                 :     1313142 :           bitmap_clear (&bb_info->sparse_kill);
     220                 :     1313142 :           bitmap_clear (&bb_info->gen);
     221                 :             :         }
     222                 :             :       else
     223                 :             :         {
     224                 :    59161135 :           bitmap_initialize (&bb_info->kill, &problem_data->rd_bitmaps);
     225                 :    59161135 :           bitmap_initialize (&bb_info->sparse_kill, &problem_data->rd_bitmaps);
     226                 :    59161135 :           bitmap_initialize (&bb_info->gen, &problem_data->rd_bitmaps);
     227                 :    59161135 :           bitmap_initialize (&bb_info->in, &problem_data->rd_bitmaps);
     228                 :    59161135 :           bitmap_initialize (&bb_info->out, &problem_data->rd_bitmaps);
     229                 :             :         }
     230                 :             :     }
     231                 :     5566829 :   df_rd->optional_p = true;
     232                 :     5566829 : }
     233                 :             : 
     234                 :             : 
     235                 :             : /* Add the effect of the top artificial defs of BB to the reaching definitions
     236                 :             :    bitmap LOCAL_RD.  */
     237                 :             : 
     238                 :             : void
     239                 :    60474277 : df_rd_simulate_artificial_defs_at_top (basic_block bb, bitmap local_rd)
     240                 :             : {
     241                 :    60474277 :   int bb_index = bb->index;
     242                 :    60474277 :   df_ref def;
     243                 :   199717453 :   FOR_EACH_ARTIFICIAL_DEF (def, bb_index)
     244                 :    78768899 :     if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
     245                 :             :       {
     246                 :     1822785 :         unsigned int dregno = DF_REF_REGNO (def);
     247                 :     1822785 :         if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
     248                 :     1822785 :           bitmap_clear_range (local_rd,
     249                 :     1822785 :                               DF_DEFS_BEGIN (dregno),
     250                 :     1822785 :                               DF_DEFS_COUNT (dregno));
     251                 :     1822785 :         bitmap_set_bit (local_rd, DF_REF_ID (def));
     252                 :             :       }
     253                 :    60474277 : }
     254                 :             : 
     255                 :             : /* Add the effect of the defs of INSN to the reaching definitions bitmap
     256                 :             :    LOCAL_RD.  */
     257                 :             : 
     258                 :             : void
     259                 :   494399431 : df_rd_simulate_one_insn (basic_block bb ATTRIBUTE_UNUSED, rtx_insn *insn,
     260                 :             :                          bitmap local_rd)
     261                 :             : {
     262                 :   494399431 :   df_ref def;
     263                 :             : 
     264                 :  2489920444 :   FOR_EACH_INSN_DEF (def, insn)
     265                 :             :     {
     266                 :  1995521013 :       unsigned int dregno = DF_REF_REGNO (def);
     267                 :  1995521013 :       if ((!(df->changeable_flags & DF_NO_HARD_REGS))
     268                 :    14034251 :           || (dregno >= FIRST_PSEUDO_REGISTER))
     269                 :             :         {
     270                 :  1983114856 :           if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
     271                 :  1982482616 :             bitmap_clear_range (local_rd,
     272                 :  1982482616 :                                 DF_DEFS_BEGIN (dregno),
     273                 :  1982482616 :                                 DF_DEFS_COUNT (dregno));
     274                 :  1983114856 :           if (!(DF_REF_FLAGS (def)
     275                 :             :                 & (DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER)))
     276                 :   206901125 :             bitmap_set_bit (local_rd, DF_REF_ID (def));
     277                 :             :         }
     278                 :             :     }
     279                 :   494399431 : }
     280                 :             : 
     281                 :             : /* Process a list of DEFs for df_rd_bb_local_compute.  This is a bit
     282                 :             :    more complicated than just simulating, because we must produce the
     283                 :             :    gen and kill sets and hence deal with the two possible representations
     284                 :             :    of kill sets.   */
     285                 :             : 
     286                 :             : static void
     287                 :   614374337 : df_rd_bb_local_compute_process_def (class df_rd_bb_info *bb_info,
     288                 :             :                                     df_ref def,
     289                 :             :                                     int top_flag)
     290                 :             : {
     291                 :  2766653954 :   for (; def; def = DF_REF_NEXT_LOC (def))
     292                 :             :     {
     293                 :  2152279617 :       if (top_flag == (DF_REF_FLAGS (def) & DF_REF_AT_TOP))
     294                 :             :         {
     295                 :  2073900315 :           unsigned int regno = DF_REF_REGNO (def);
     296                 :  2073900315 :           unsigned int begin = DF_DEFS_BEGIN (regno);
     297                 :  2073900315 :           unsigned int n_defs = DF_DEFS_COUNT (regno);
     298                 :             : 
     299                 :  2073900315 :           if ((!(df->changeable_flags & DF_NO_HARD_REGS))
     300                 :    14034251 :               || (regno >= FIRST_PSEUDO_REGISTER))
     301                 :             :             {
     302                 :             :               /* Only the last def(s) for a regno in the block has any
     303                 :             :                  effect.  */
     304                 :  2061494158 :               if (!bitmap_bit_p (&seen_in_block, regno))
     305                 :             :                 {
     306                 :             :                   /* The first def for regno in insn gets to knock out the
     307                 :             :                      defs from other instructions.  */
     308                 :  1490926631 :                   if ((!bitmap_bit_p (&seen_in_insn, regno))
     309                 :             :                       /* If the def is to only part of the reg, it does
     310                 :             :                          not kill the other defs that reach here.  */
     311                 :  1490926631 :                       && (!(DF_REF_FLAGS (def) &
     312                 :             :                             (DF_REF_PARTIAL | DF_REF_CONDITIONAL | DF_REF_MAY_CLOBBER))))
     313                 :             :                     {
     314                 :   217551227 :                       if (n_defs > DF_SPARSE_THRESHOLD)
     315                 :             :                         {
     316                 :    36308385 :                           bitmap_set_bit (&bb_info->sparse_kill, regno);
     317                 :    36308385 :                           bitmap_clear_range (&bb_info->gen, begin, n_defs);
     318                 :             :                         }
     319                 :             :                       else
     320                 :             :                         {
     321                 :   181242842 :                           bitmap_set_range (&bb_info->kill, begin, n_defs);
     322                 :   181242842 :                           bitmap_clear_range (&bb_info->gen, begin, n_defs);
     323                 :             :                         }
     324                 :             :                     }
     325                 :             : 
     326                 :  1490926631 :                   bitmap_set_bit (&seen_in_insn, regno);
     327                 :             :                   /* All defs for regno in the instruction may be put into
     328                 :             :                      the gen set.  */
     329                 :  1490926631 :                   if (!(DF_REF_FLAGS (def)
     330                 :             :                         & (DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER)))
     331                 :   211408013 :                     bitmap_set_bit (&bb_info->gen, DF_REF_ID (def));
     332                 :             :                 }
     333                 :             :             }
     334                 :             :         }
     335                 :             :     }
     336                 :   614374337 : }
     337                 :             : 
     338                 :             : /* Compute local reaching def info for basic block BB.  */
     339                 :             : 
     340                 :             : static void
     341                 :    60474277 : df_rd_bb_local_compute (unsigned int bb_index)
     342                 :             : {
     343                 :    60474277 :   basic_block bb = BASIC_BLOCK_FOR_FN (cfun, bb_index);
     344                 :    60474277 :   class df_rd_bb_info *bb_info = df_rd_get_bb_info (bb_index);
     345                 :    60474277 :   rtx_insn *insn;
     346                 :             : 
     347                 :    60474277 :   bitmap_clear (&seen_in_block);
     348                 :    60474277 :   bitmap_clear (&seen_in_insn);
     349                 :             : 
     350                 :             :   /* Artificials are only hard regs.  */
     351                 :    60474277 :   if (!(df->changeable_flags & DF_NO_HARD_REGS))
     352                 :   119974906 :     df_rd_bb_local_compute_process_def (bb_info,
     353                 :             :                                         df_get_artificial_defs (bb_index),
     354                 :             :                                         0);
     355                 :             : 
     356                 :   651383499 :   FOR_BB_INSNS_REVERSE (bb, insn)
     357                 :             :     {
     358                 :   590909222 :       unsigned int uid = INSN_UID (insn);
     359                 :             : 
     360                 :   590909222 :       if (!INSN_P (insn))
     361                 :    96509791 :         continue;
     362                 :             : 
     363                 :   494399431 :       df_rd_bb_local_compute_process_def (bb_info,
     364                 :   494399431 :                                           DF_INSN_UID_DEFS (uid), 0);
     365                 :             : 
     366                 :             :       /* This complex dance with the two bitmaps is required because
     367                 :             :          instructions can assign twice to the same pseudo.  This
     368                 :             :          generally happens with calls that will have one def for the
     369                 :             :          result and another def for the clobber.  If only one vector
     370                 :             :          is used and the clobber goes first, the result will be
     371                 :             :          lost.  */
     372                 :   494399431 :       bitmap_ior_into (&seen_in_block, &seen_in_insn);
     373                 :   494399431 :       bitmap_clear (&seen_in_insn);
     374                 :             :     }
     375                 :             : 
     376                 :             :   /* Process the artificial defs at the top of the block last since we
     377                 :             :      are going backwards through the block and these are logically at
     378                 :             :      the start.  */
     379                 :    60474277 :   if (!(df->changeable_flags & DF_NO_HARD_REGS))
     380                 :   119974906 :     df_rd_bb_local_compute_process_def (bb_info,
     381                 :             :                                         df_get_artificial_defs (bb_index),
     382                 :             :                                         DF_REF_AT_TOP);
     383                 :    60474277 : }
     384                 :             : 
     385                 :             : 
     386                 :             : /* Compute local reaching def info for each basic block within BLOCKS.  */
     387                 :             : 
     388                 :             : static void
     389                 :     5566829 : df_rd_local_compute (bitmap all_blocks)
     390                 :             : {
     391                 :     5566829 :   unsigned int bb_index;
     392                 :     5566829 :   bitmap_iterator bi;
     393                 :     5566829 :   class df_rd_problem_data *problem_data
     394                 :     5566829 :     = (class df_rd_problem_data *) df_rd->problem_data;
     395                 :     5566829 :   bitmap sparse_invalidated = &problem_data->sparse_invalidated_by_eh;
     396                 :     5566829 :   bitmap dense_invalidated = &problem_data->dense_invalidated_by_eh;
     397                 :             : 
     398                 :     5566829 :   bitmap_initialize (&seen_in_block, &df_bitmap_obstack);
     399                 :     5566829 :   bitmap_initialize (&seen_in_insn, &df_bitmap_obstack);
     400                 :             : 
     401                 :     5566829 :   df_maybe_reorganize_def_refs (DF_REF_ORDER_BY_REG);
     402                 :             : 
     403                 :    66041106 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
     404                 :             :     {
     405                 :    60474277 :       df_rd_bb_local_compute (bb_index);
     406                 :             :     }
     407                 :             : 
     408                 :             :   /* Set up the knockout bit vectors to be applied across EH_EDGES.
     409                 :             :      Conservatively treat partially-clobbered registers as surviving
     410                 :             :      across the EH edge, i.e. assume that definitions before the edge
     411                 :             :      is taken *might* reach uses after it has been taken.  */
     412                 :     5566829 :   if (!(df->changeable_flags & DF_NO_HARD_REGS))
     413                 :   515805714 :     for (unsigned int regno = 0; regno < FIRST_PSEUDO_REGISTER; ++regno)
     414                 :   510259416 :       if (eh_edge_abi.clobbers_full_reg_p (regno))
     415                 :             :         {
     416                 :   460252525 :           if (DF_DEFS_COUNT (regno) > DF_SPARSE_THRESHOLD)
     417                 :     9594782 :             bitmap_set_bit (sparse_invalidated, regno);
     418                 :             :           else
     419                 :   450657743 :             bitmap_set_range (dense_invalidated,
     420                 :   450657743 :                               DF_DEFS_BEGIN (regno),
     421                 :             :                               DF_DEFS_COUNT (regno));
     422                 :             :         }
     423                 :             : 
     424                 :     5566829 :   bitmap_release (&seen_in_block);
     425                 :     5566829 :   bitmap_release (&seen_in_insn);
     426                 :     5566829 : }
     427                 :             : 
     428                 :             : 
     429                 :             : /* Initialize the solution bit vectors for problem.  */
     430                 :             : 
     431                 :             : static void
     432                 :     5566829 : df_rd_init_solution (bitmap all_blocks)
     433                 :             : {
     434                 :     5566829 :   unsigned int bb_index;
     435                 :     5566829 :   bitmap_iterator bi;
     436                 :             : 
     437                 :    66041106 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
     438                 :             :     {
     439                 :    60474277 :       class df_rd_bb_info *bb_info = df_rd_get_bb_info (bb_index);
     440                 :             : 
     441                 :    60474277 :       bitmap_copy (&bb_info->out, &bb_info->gen);
     442                 :    60474277 :       bitmap_clear (&bb_info->in);
     443                 :             :     }
     444                 :     5566829 : }
     445                 :             : 
     446                 :             : /* In of target gets or of out of source.  */
     447                 :             : 
     448                 :             : static bool
     449                 :    96806355 : df_rd_confluence_n (edge e)
     450                 :             : {
     451                 :    96806355 :   bitmap op1 = &df_rd_get_bb_info (e->dest->index)->in;
     452                 :    96806355 :   bitmap op2 = &df_rd_get_bb_info (e->src->index)->out;
     453                 :    96806355 :   bool changed = false;
     454                 :             : 
     455                 :    96806355 :   if (e->flags & EDGE_FAKE)
     456                 :             :     return false;
     457                 :             : 
     458                 :    96806355 :   if (e->flags & EDGE_EH)
     459                 :             :     {
     460                 :     3341685 :       class df_rd_problem_data *problem_data
     461                 :             :         = (class df_rd_problem_data *) df_rd->problem_data;
     462                 :     3341685 :       bitmap sparse_invalidated = &problem_data->sparse_invalidated_by_eh;
     463                 :     3341685 :       bitmap dense_invalidated = &problem_data->dense_invalidated_by_eh;
     464                 :     3341685 :       bitmap_iterator bi;
     465                 :     3341685 :       unsigned int regno;
     466                 :             : 
     467                 :     3341685 :       auto_bitmap tmp (&df_bitmap_obstack);
     468                 :     3341685 :       bitmap_and_compl (tmp, op2, dense_invalidated);
     469                 :             : 
     470                 :   190929229 :       EXECUTE_IF_SET_IN_BITMAP (sparse_invalidated, 0, regno, bi)
     471                 :             :         {
     472                 :   187587544 :           bitmap_clear_range (tmp,
     473                 :   187587544 :                               DF_DEFS_BEGIN (regno),
     474                 :   187587544 :                               DF_DEFS_COUNT (regno));
     475                 :             :         }
     476                 :     3341685 :       changed |= bitmap_ior_into (op1, tmp);
     477                 :     3341685 :       return changed;
     478                 :     3341685 :     }
     479                 :             :   else
     480                 :    93464670 :     return bitmap_ior_into (op1, op2);
     481                 :             : }
     482                 :             : 
     483                 :             : 
     484                 :             : /* Transfer function.  */
     485                 :             : 
     486                 :             : static bool
     487                 :    70222362 : df_rd_transfer_function (int bb_index)
     488                 :             : {
     489                 :    70222362 :   class df_rd_bb_info *bb_info = df_rd_get_bb_info (bb_index);
     490                 :    70222362 :   unsigned int regno;
     491                 :    70222362 :   bitmap_iterator bi;
     492                 :    70222362 :   bitmap in = &bb_info->in;
     493                 :    70222362 :   bitmap out = &bb_info->out;
     494                 :    70222362 :   bitmap gen = &bb_info->gen;
     495                 :    70222362 :   bitmap kill = &bb_info->kill;
     496                 :    70222362 :   bitmap sparse_kill = &bb_info->sparse_kill;
     497                 :    70222362 :   bool changed = false;
     498                 :             : 
     499                 :    70222362 :   if (bitmap_empty_p (sparse_kill))
     500                 :    42869048 :     changed = bitmap_ior_and_compl (out, gen, in, kill);
     501                 :             :   else
     502                 :             :     {
     503                 :    27353314 :       class df_rd_problem_data *problem_data;
     504                 :    27353314 :       bitmap_head tmp;
     505                 :             : 
     506                 :             :       /* Note that TMP is _not_ a temporary bitmap if we end up replacing
     507                 :             :          OUT with TMP.  Therefore, allocate TMP in the RD bitmaps obstack.  */
     508                 :    27353314 :       problem_data = (class df_rd_problem_data *) df_rd->problem_data;
     509                 :    27353314 :       bitmap_initialize (&tmp, &problem_data->rd_bitmaps);
     510                 :             : 
     511                 :    27353314 :       bitmap_and_compl (&tmp, in, kill);
     512                 :    70344844 :       EXECUTE_IF_SET_IN_BITMAP (sparse_kill, 0, regno, bi)
     513                 :             :         {
     514                 :    42991530 :           bitmap_clear_range (&tmp,
     515                 :    42991530 :                               DF_DEFS_BEGIN (regno),
     516                 :    42991530 :                               DF_DEFS_COUNT (regno));
     517                 :             :         }
     518                 :    27353314 :       bitmap_ior_into (&tmp, gen);
     519                 :    27353314 :       changed = !bitmap_equal_p (&tmp, out);
     520                 :    27353314 :       if (changed)
     521                 :    26805482 :         bitmap_move (out, &tmp);
     522                 :             :       else
     523                 :      547832 :         bitmap_clear (&tmp);
     524                 :             :     }
     525                 :             : 
     526                 :    70222362 :   if (df->changeable_flags & DF_RD_PRUNE_DEAD_DEFS)
     527                 :             :     {
     528                 :             :       /* Create a mask of DEFs for all registers live at the end of this
     529                 :             :          basic block, and mask out DEFs of registers that are not live.
     530                 :             :          Computing the mask looks costly, but the benefit of the pruning
     531                 :             :          outweighs the cost.  */
     532                 :    70221271 :       class df_rd_bb_info *bb_info = df_rd_get_bb_info (bb_index);
     533                 :    70221271 :       bitmap regs_live_out = &df_lr_get_bb_info (bb_index)->out;
     534                 :    70221271 :       bitmap live_defs = BITMAP_ALLOC (&df_bitmap_obstack);
     535                 :    70221271 :       unsigned int regno;
     536                 :    70221271 :       bitmap_iterator bi;
     537                 :             : 
     538                 :   748656365 :       EXECUTE_IF_SET_IN_BITMAP (regs_live_out, 0, regno, bi)
     539                 :   678435094 :         bitmap_set_range (live_defs,
     540                 :   678435094 :                           DF_DEFS_BEGIN (regno),
     541                 :   678435094 :                           DF_DEFS_COUNT (regno));
     542                 :    70221271 :       changed |= bitmap_and_into (&bb_info->out, live_defs);
     543                 :    70221271 :       BITMAP_FREE (live_defs);
     544                 :             :     }
     545                 :             : 
     546                 :    70222362 :   return changed;
     547                 :             : }
     548                 :             : 
     549                 :             : /* Free all storage associated with the problem.  */
     550                 :             : 
     551                 :             : static void
     552                 :     4812811 : df_rd_free (void)
     553                 :             : {
     554                 :     4812811 :   class df_rd_problem_data *problem_data
     555                 :     4812811 :     = (class df_rd_problem_data *) df_rd->problem_data;
     556                 :             : 
     557                 :     4812811 :   if (problem_data)
     558                 :             :     {
     559                 :     4812811 :       bitmap_obstack_release (&problem_data->rd_bitmaps);
     560                 :             : 
     561                 :     4812811 :       df_rd->block_info_size = 0;
     562                 :     4812811 :       free (df_rd->block_info);
     563                 :     4812811 :       df_rd->block_info = NULL;
     564                 :     4812811 :       free (df_rd->problem_data);
     565                 :             :     }
     566                 :     4812811 :   free (df_rd);
     567                 :     4812811 : }
     568                 :             : 
     569                 :             : 
     570                 :             : /* Debugging info.  */
     571                 :             : 
     572                 :             : static void
     573                 :         236 : df_rd_start_dump (FILE *file)
     574                 :             : {
     575                 :         236 :   class df_rd_problem_data *problem_data
     576                 :         236 :     = (class df_rd_problem_data *) df_rd->problem_data;
     577                 :         236 :   unsigned int m = DF_REG_SIZE (df);
     578                 :         236 :   unsigned int regno;
     579                 :             : 
     580                 :         236 :   if (!df_rd->block_info)
     581                 :             :     return;
     582                 :             : 
     583                 :         236 :   fprintf (file, ";; Reaching defs:\n");
     584                 :             : 
     585                 :         236 :   fprintf (file, ";;  sparse invalidated \t");
     586                 :         236 :   dump_bitmap (file, &problem_data->sparse_invalidated_by_eh);
     587                 :         236 :   fprintf (file, ";;  dense invalidated \t");
     588                 :         236 :   dump_bitmap (file, &problem_data->dense_invalidated_by_eh);
     589                 :             : 
     590                 :         236 :   fprintf (file, ";;  reg->defs[] map:\t");
     591                 :       30355 :   for (regno = 0; regno < m; regno++)
     592                 :       29883 :     if (DF_DEFS_COUNT (regno))
     593                 :       16123 :       fprintf (file, "%d[%d,%d] ", regno,
     594                 :             :                DF_DEFS_BEGIN (regno),
     595                 :       16123 :                DF_DEFS_BEGIN (regno) + DF_DEFS_COUNT (regno) - 1);
     596                 :         236 :   fprintf (file, "\n");
     597                 :             : }
     598                 :             : 
     599                 :             : 
     600                 :             : static void
     601                 :        2684 : df_rd_dump_defs_set (bitmap defs_set, const char *prefix, FILE *file)
     602                 :             : {
     603                 :        2684 :   bitmap_head tmp;
     604                 :        2684 :   unsigned int regno;
     605                 :        2684 :   unsigned int m = DF_REG_SIZE (df);
     606                 :        2684 :   bool first_reg = true;
     607                 :             : 
     608                 :        2684 :   fprintf (file, "%s\t(%d) ", prefix, (int) bitmap_count_bits (defs_set));
     609                 :             : 
     610                 :        2684 :   bitmap_initialize (&tmp, &df_bitmap_obstack);
     611                 :      397108 :   for (regno = 0; regno < m; regno++)
     612                 :             :     {
     613                 :      394424 :       if (HARD_REGISTER_NUM_P (regno)
     614                 :      246928 :           && (df->changeable_flags & DF_NO_HARD_REGS))
     615                 :           0 :         continue;
     616                 :      394424 :       bitmap_set_range (&tmp, DF_DEFS_BEGIN (regno), DF_DEFS_COUNT (regno));
     617                 :      394424 :       bitmap_and_into (&tmp, defs_set);
     618                 :      394424 :       if (! bitmap_empty_p (&tmp))
     619                 :             :         {
     620                 :        8889 :           bitmap_iterator bi;
     621                 :        8889 :           unsigned int ix;
     622                 :        8889 :           bool first_def = true;
     623                 :             : 
     624                 :        8889 :           if (! first_reg)
     625                 :        6742 :             fprintf (file, ",");
     626                 :        8889 :           first_reg = false;
     627                 :             : 
     628                 :        8889 :           fprintf (file, "%u[", regno);
     629                 :       19733 :           EXECUTE_IF_SET_IN_BITMAP (&tmp, 0, ix, bi)
     630                 :             :             {
     631                 :       12799 :               fprintf (file, "%s%u", first_def ? "" : ",", ix);
     632                 :       10844 :               first_def = false;
     633                 :             :             }
     634                 :        8889 :           fprintf (file, "]");
     635                 :             :         }
     636                 :      394424 :       bitmap_clear (&tmp);
     637                 :             :     }
     638                 :             : 
     639                 :        2684 :   fprintf (file, "\n");
     640                 :        2684 :   bitmap_clear (&tmp);
     641                 :        2684 : }
     642                 :             : 
     643                 :             : /* Debugging info at top of bb.  */
     644                 :             : 
     645                 :             : static void
     646                 :         671 : df_rd_top_dump (basic_block bb, FILE *file)
     647                 :             : {
     648                 :         671 :   class df_rd_bb_info *bb_info = df_rd_get_bb_info (bb->index);
     649                 :         671 :   if (!bb_info)
     650                 :             :     return;
     651                 :             : 
     652                 :         671 :   df_rd_dump_defs_set (&bb_info->in, ";; rd  in  ", file);
     653                 :         671 :   df_rd_dump_defs_set (&bb_info->gen, ";; rd  gen ", file);
     654                 :         671 :   df_rd_dump_defs_set (&bb_info->kill, ";; rd  kill", file);
     655                 :             : }
     656                 :             : 
     657                 :             : 
     658                 :             : /* Debugging info at bottom of bb.  */
     659                 :             : 
     660                 :             : static void
     661                 :         671 : df_rd_bottom_dump (basic_block bb, FILE *file)
     662                 :             : {
     663                 :         671 :   class df_rd_bb_info *bb_info = df_rd_get_bb_info (bb->index);
     664                 :         671 :   if (!bb_info)
     665                 :             :     return;
     666                 :             : 
     667                 :         671 :   df_rd_dump_defs_set (&bb_info->out, ";; rd  out ", file);
     668                 :             : }
     669                 :             : 
     670                 :             : /* All of the information associated with every instance of the problem.  */
     671                 :             : 
     672                 :             : static const struct df_problem problem_RD =
     673                 :             : {
     674                 :             :   DF_RD,                      /* Problem id.  */
     675                 :             :   DF_FORWARD,                 /* Direction.  */
     676                 :             :   df_rd_alloc,                /* Allocate the problem specific data.  */
     677                 :             :   NULL,                       /* Reset global information.  */
     678                 :             :   df_rd_free_bb_info,         /* Free basic block info.  */
     679                 :             :   df_rd_local_compute,        /* Local compute function.  */
     680                 :             :   df_rd_init_solution,        /* Init the solution specific data.  */
     681                 :             :   df_worklist_dataflow,       /* Worklist solver.  */
     682                 :             :   NULL,                       /* Confluence operator 0.  */
     683                 :             :   df_rd_confluence_n,         /* Confluence operator n.  */
     684                 :             :   df_rd_transfer_function,    /* Transfer function.  */
     685                 :             :   NULL,                       /* Finalize function.  */
     686                 :             :   df_rd_free,                 /* Free all of the problem information.  */
     687                 :             :   df_rd_free,                 /* Remove this problem from the stack of dataflow problems.  */
     688                 :             :   df_rd_start_dump,           /* Debugging.  */
     689                 :             :   df_rd_top_dump,             /* Debugging start block.  */
     690                 :             :   df_rd_bottom_dump,          /* Debugging end block.  */
     691                 :             :   NULL,                       /* Debugging start insn.  */
     692                 :             :   NULL,                       /* Debugging end insn.  */
     693                 :             :   NULL,                       /* Incremental solution verify start.  */
     694                 :             :   NULL,                       /* Incremental solution verify end.  */
     695                 :             :   NULL,                       /* Dependent problem.  */
     696                 :             :   sizeof (class df_rd_bb_info),/* Size of entry of block_info array.  */
     697                 :             :   TV_DF_RD,                   /* Timing variable.  */
     698                 :             :   true                        /* Reset blocks on dropping out of blocks_to_analyze.  */
     699                 :             : };
     700                 :             : 
     701                 :             : 
     702                 :             : 
     703                 :             : /* Create a new RD instance and add it to the existing instance
     704                 :             :    of DF.  */
     705                 :             : 
     706                 :             : void
     707                 :         104 : df_rd_add_problem (void)
     708                 :             : {
     709                 :         104 :   df_add_problem (&problem_RD);
     710                 :         104 : }
     711                 :             : 
     712                 :             : 
     713                 :             : 
     714                 :             : /*----------------------------------------------------------------------------
     715                 :             :    LIVE REGISTERS
     716                 :             : 
     717                 :             :    Find the locations in the function where any use of a pseudo can
     718                 :             :    reach in the backwards direction.  In and out bitvectors are built
     719                 :             :    for each basic block.  The regno is used to index into these sets.
     720                 :             :    See df.h for details.
     721                 :             :    ----------------------------------------------------------------------------*/
     722                 :             : 
     723                 :             : /* Private data used to verify the solution for this problem.  */
     724                 :             : struct df_lr_problem_data
     725                 :             : {
     726                 :             :   bitmap_head *in;
     727                 :             :   bitmap_head *out;
     728                 :             :   /* An obstack for the bitmaps we need for this problem.  */
     729                 :             :   bitmap_obstack lr_bitmaps;
     730                 :             : };
     731                 :             : 
     732                 :             : /* Free basic block info.  */
     733                 :             : 
     734                 :             : static void
     735                 :     5879533 : df_lr_free_bb_info (basic_block bb ATTRIBUTE_UNUSED,
     736                 :             :                     void *vbb_info)
     737                 :             : {
     738                 :     5879533 :   class df_lr_bb_info *bb_info = (class df_lr_bb_info *) vbb_info;
     739                 :     5879533 :   if (bb_info)
     740                 :             :     {
     741                 :     5879533 :       bitmap_clear (&bb_info->use);
     742                 :     5879533 :       bitmap_clear (&bb_info->def);
     743                 :     5879533 :       bitmap_clear (&bb_info->in);
     744                 :     5879533 :       bitmap_clear (&bb_info->out);
     745                 :             :     }
     746                 :     5879533 : }
     747                 :             : 
     748                 :             : 
     749                 :             : /* Allocate or reset bitmaps for DF_LR blocks. The solution bits are
     750                 :             :    not touched unless the block is new.  */
     751                 :             : 
     752                 :             : static void
     753                 :    13645285 : df_lr_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
     754                 :             : {
     755                 :    13645285 :   unsigned int bb_index;
     756                 :    13645285 :   bitmap_iterator bi;
     757                 :    13645285 :   struct df_lr_problem_data *problem_data;
     758                 :             : 
     759                 :    13645285 :   df_grow_bb_info (df_lr);
     760                 :    13645285 :   if (df_lr->problem_data)
     761                 :             :     problem_data = (struct df_lr_problem_data *) df_lr->problem_data;
     762                 :             :   else
     763                 :             :     {
     764                 :     1426765 :       problem_data = XNEW (struct df_lr_problem_data);
     765                 :     1426765 :       df_lr->problem_data = problem_data;
     766                 :             : 
     767                 :     1426765 :       problem_data->out = NULL;
     768                 :     1426765 :       problem_data->in = NULL;
     769                 :     1426765 :       bitmap_obstack_initialize (&problem_data->lr_bitmaps);
     770                 :             :     }
     771                 :             : 
     772                 :    91505552 :   EXECUTE_IF_SET_IN_BITMAP (df_lr->out_of_date_transfer_functions, 0, bb_index, bi)
     773                 :             :     {
     774                 :    77860267 :       class df_lr_bb_info *bb_info = df_lr_get_bb_info (bb_index);
     775                 :             :       
     776                 :             :       /* When bitmaps are already initialized, just clear them.  */
     777                 :    77860267 :       if (bb_info->use.obstack)
     778                 :             :         {
     779                 :    56996959 :           bitmap_clear (&bb_info->def);
     780                 :    56996959 :           bitmap_clear (&bb_info->use);
     781                 :             :         }
     782                 :             :       else
     783                 :             :         {
     784                 :    20863308 :           bitmap_initialize (&bb_info->use, &problem_data->lr_bitmaps);
     785                 :    20863308 :           bitmap_initialize (&bb_info->def, &problem_data->lr_bitmaps);
     786                 :    20863308 :           bitmap_initialize (&bb_info->in, &problem_data->lr_bitmaps);
     787                 :    20863308 :           bitmap_initialize (&bb_info->out, &problem_data->lr_bitmaps);
     788                 :             :         }
     789                 :             :     }
     790                 :             : 
     791                 :    13645285 :   df_lr->optional_p = false;
     792                 :    13645285 : }
     793                 :             : 
     794                 :             : 
     795                 :             : /* Reset the global solution for recalculation.  */
     796                 :             : 
     797                 :             : static void
     798                 :           0 : df_lr_reset (bitmap all_blocks)
     799                 :             : {
     800                 :           0 :   unsigned int bb_index;
     801                 :           0 :   bitmap_iterator bi;
     802                 :             : 
     803                 :           0 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
     804                 :             :     {
     805                 :           0 :       class df_lr_bb_info *bb_info = df_lr_get_bb_info (bb_index);
     806                 :           0 :       gcc_assert (bb_info);
     807                 :           0 :       bitmap_clear (&bb_info->in);
     808                 :           0 :       bitmap_clear (&bb_info->out);
     809                 :             :     }
     810                 :           0 : }
     811                 :             : 
     812                 :             : 
     813                 :             : /* Compute local live register info for basic block BB.  */
     814                 :             : 
     815                 :             : static void
     816                 :    74544128 : df_lr_bb_local_compute (unsigned int bb_index)
     817                 :             : {
     818                 :    74544128 :   basic_block bb = BASIC_BLOCK_FOR_FN (cfun, bb_index);
     819                 :    74544128 :   class df_lr_bb_info *bb_info = df_lr_get_bb_info (bb_index);
     820                 :    74544128 :   rtx_insn *insn;
     821                 :    74544128 :   df_ref def, use;
     822                 :             : 
     823                 :             :   /* Process the registers set in an exception handler.  */
     824                 :   208077531 :   FOR_EACH_ARTIFICIAL_DEF (def, bb_index)
     825                 :    58989275 :     if ((DF_REF_FLAGS (def) & DF_REF_AT_TOP) == 0)
     826                 :             :       {
     827                 :    57251127 :         unsigned int dregno = DF_REF_REGNO (def);
     828                 :    57251127 :         bitmap_set_bit (&bb_info->def, dregno);
     829                 :    57251127 :         bitmap_clear_bit (&bb_info->use, dregno);
     830                 :             :       }
     831                 :             : 
     832                 :             :   /* Process the hardware registers that are always live.  */
     833                 :   356091242 :   FOR_EACH_ARTIFICIAL_USE (use, bb_index)
     834                 :             :     /* Add use to set of uses in this BB.  */
     835                 :   207002986 :     if ((DF_REF_FLAGS (use) & DF_REF_AT_TOP) == 0)
     836                 :   207002986 :       bitmap_set_bit (&bb_info->use, DF_REF_REGNO (use));
     837                 :             : 
     838                 :  1042484791 :   FOR_BB_INSNS_REVERSE (bb, insn)
     839                 :             :     {
     840                 :   967940663 :       if (!NONDEBUG_INSN_P (insn))
     841                 :   439825945 :         continue;
     842                 :             : 
     843                 :   528114718 :       df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
     844                 :  3887256939 :       FOR_EACH_INSN_INFO_DEF (def, insn_info)
     845                 :             :         {
     846                 :             :           /* If the definition is to only part of the register, it will
     847                 :             :              usually have a corresponding use.  For example, stores to one
     848                 :             :              word of a multiword register R have both a use and a partial
     849                 :             :              definition of R.
     850                 :             : 
     851                 :             :              In those cases, the LR confluence function:
     852                 :             : 
     853                 :             :                IN = (OUT & ~DEF) | USE
     854                 :             : 
     855                 :             :              is unaffected by whether we count the partial definition or not.
     856                 :             :              However, it's more convenient for consumers if DEF contains
     857                 :             :              *all* the registers defined in a block.
     858                 :             : 
     859                 :             :              The only current case in which we record a partial definition
     860                 :             :              without a corresponding use is if the destination is the
     861                 :             :              multi-register subreg of a hard register.  An artificial
     862                 :             :              example of this is:
     863                 :             : 
     864                 :             :                 (set (subreg:TI (reg:V8HI x0) 0) (const_int -1))
     865                 :             : 
     866                 :             :              on AArch64.  This is described as a DF_REF_PARTIAL
     867                 :             :              definition of x0 and x1 with no corresponding uses.
     868                 :             :              In previous versions of GCC, the instruction had no
     869                 :             :              effect on LR (that is, LR acted as though the instruction
     870                 :             :              didn't exist).
     871                 :             : 
     872                 :             :              It seems suspect that this case is treated differently.
     873                 :             :              Either the instruction should be a full definition of x0 and x1,
     874                 :             :              or the definition should be treated in the same way as other
     875                 :             :              partial definitions, such as strict_lowparts or subregs that
     876                 :             :              satisfy read_modify_subreg_p.
     877                 :             : 
     878                 :             :              Fortunately, multi-register subregs of hard registers should
     879                 :             :              be rare.  They should be folded into a plain REG if the target
     880                 :             :              allows that (as AArch64 does for example above).
     881                 :             : 
     882                 :             :              Here we treat the cases alike by forcing a use even in the rare
     883                 :             :              case that no DF_REF_REG_USE is recorded.  That is, we model all
     884                 :             :              partial definitions as both a use and a definition of the
     885                 :             :              register.  */
     886                 :  3359142221 :           unsigned int dregno = DF_REF_REGNO (def);
     887                 :  3359142221 :           bitmap_set_bit (&bb_info->def, dregno);
     888                 :  3359142221 :           if (DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL))
     889                 :     1904514 :             bitmap_set_bit (&bb_info->use, dregno);
     890                 :             :           else
     891                 :  3357237707 :             bitmap_clear_bit (&bb_info->use, dregno);
     892                 :             :         }
     893                 :             : 
     894                 :  1193411902 :       FOR_EACH_INSN_INFO_USE (use, insn_info)
     895                 :             :         /* Add use to set of uses in this BB.  */
     896                 :   665297184 :         bitmap_set_bit (&bb_info->use, DF_REF_REGNO (use));
     897                 :             :     }
     898                 :             : 
     899                 :             :   /* Process the registers set in an exception handler or the hard
     900                 :             :      frame pointer if this block is the target of a non local
     901                 :             :      goto.  */
     902                 :   208077531 :   FOR_EACH_ARTIFICIAL_DEF (def, bb_index)
     903                 :    58989275 :     if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
     904                 :             :       {
     905                 :     1738148 :         unsigned int dregno = DF_REF_REGNO (def);
     906                 :     1738148 :         bitmap_set_bit (&bb_info->def, dregno);
     907                 :     1738148 :         bitmap_clear_bit (&bb_info->use, dregno);
     908                 :             :       }
     909                 :             : 
     910                 :             : #ifdef EH_USES
     911                 :             :   /* Process the uses that are live into an exception handler.  */
     912                 :             :   FOR_EACH_ARTIFICIAL_USE (use, bb_index)
     913                 :             :     /* Add use to set of uses in this BB.  */
     914                 :             :     if (DF_REF_FLAGS (use) & DF_REF_AT_TOP)
     915                 :             :       bitmap_set_bit (&bb_info->use, DF_REF_REGNO (use));
     916                 :             : #endif
     917                 :             : 
     918                 :             :   /* If the df_live problem is not defined, such as at -O0 and -O1, we
     919                 :             :      still need to keep the luids up to date.  This is normally done
     920                 :             :      in the df_live problem since this problem has a forwards
     921                 :             :      scan.  */
     922                 :    74544128 :   if (!df_live)
     923                 :    12349152 :     df_recompute_luids (bb);
     924                 :    74544128 : }
     925                 :             : 
     926                 :             : 
     927                 :             : /* Compute local live register info for each basic block within BLOCKS.  */
     928                 :             : 
     929                 :             : static void
     930                 :    13645285 : df_lr_local_compute (bitmap all_blocks ATTRIBUTE_UNUSED)
     931                 :             : {
     932                 :    13645285 :   unsigned int bb_index, i;
     933                 :    13645285 :   bitmap_iterator bi;
     934                 :             : 
     935                 :    13645285 :   bitmap_clear (&df->hardware_regs_used);
     936                 :             : 
     937                 :             :   /* The all-important stack pointer must always be live.  */
     938                 :    13645285 :   bitmap_set_bit (&df->hardware_regs_used, STACK_POINTER_REGNUM);
     939                 :             : 
     940                 :             :   /* Global regs are always live, too.  */
     941                 :  1282656790 :   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
     942                 :  1255366220 :     if (global_regs[i])
     943                 :        1362 :       bitmap_set_bit (&df->hardware_regs_used, i);
     944                 :             : 
     945                 :             :   /* Before reload, there are a few registers that must be forced
     946                 :             :      live everywhere -- which might not already be the case for
     947                 :             :      blocks within infinite loops.  */
     948                 :    13645285 :   if (!reload_completed)
     949                 :             :     {
     950                 :     8588680 :       unsigned int pic_offset_table_regnum = PIC_OFFSET_TABLE_REGNUM;
     951                 :             :       /* Any reference to any pseudo before reload is a potential
     952                 :             :          reference of the frame pointer.  */
     953                 :     8588680 :       bitmap_set_bit (&df->hardware_regs_used, FRAME_POINTER_REGNUM);
     954                 :             : 
     955                 :             :       /* Pseudos with argument area equivalences may require
     956                 :             :          reloading via the argument pointer.  */
     957                 :     8588680 :       if (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
     958                 :     8588680 :           && fixed_regs[ARG_POINTER_REGNUM])
     959                 :     8588680 :         bitmap_set_bit (&df->hardware_regs_used, ARG_POINTER_REGNUM);
     960                 :             : 
     961                 :             :       /* Any constant, or pseudo with constant equivalences, may
     962                 :             :          require reloading from memory using the pic register.  */
     963                 :     8588680 :       if (pic_offset_table_regnum != INVALID_REGNUM
     964                 :           0 :           && fixed_regs[pic_offset_table_regnum])
     965                 :           0 :         bitmap_set_bit (&df->hardware_regs_used, pic_offset_table_regnum);
     966                 :             :     }
     967                 :             : 
     968                 :    91505552 :   EXECUTE_IF_SET_IN_BITMAP (df_lr->out_of_date_transfer_functions, 0, bb_index, bi)
     969                 :             :     {
     970                 :    77860267 :       if (bb_index == EXIT_BLOCK)
     971                 :             :         {
     972                 :             :           /* The exit block is special for this problem and its bits are
     973                 :             :              computed from thin air.  */
     974                 :     3316139 :           class df_lr_bb_info *bb_info = df_lr_get_bb_info (EXIT_BLOCK);
     975                 :     3316139 :           bitmap_copy (&bb_info->use, df->exit_block_uses);
     976                 :             :         }
     977                 :             :       else
     978                 :    74544128 :         df_lr_bb_local_compute (bb_index);
     979                 :             :     }
     980                 :             : 
     981                 :    13645285 :   bitmap_clear (df_lr->out_of_date_transfer_functions);
     982                 :    13645285 : }
     983                 :             : 
     984                 :             : 
     985                 :             : /* Initialize the solution vectors.  */
     986                 :             : 
     987                 :             : static void
     988                 :    13645285 : df_lr_init (bitmap all_blocks)
     989                 :             : {
     990                 :    13645285 :   unsigned int bb_index;
     991                 :    13645285 :   bitmap_iterator bi;
     992                 :             : 
     993                 :   298493437 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
     994                 :             :     {
     995                 :   284848152 :       class df_lr_bb_info *bb_info = df_lr_get_bb_info (bb_index);
     996                 :   284848152 :       bitmap_copy (&bb_info->in, &bb_info->use);
     997                 :   284848152 :       bitmap_clear (&bb_info->out);
     998                 :             :     }
     999                 :    13645285 : }
    1000                 :             : 
    1001                 :             : 
    1002                 :             : /* Confluence function that processes infinite loops.  This might be a
    1003                 :             :    noreturn function that throws.  And even if it isn't, getting the
    1004                 :             :    unwind info right helps debugging.  */
    1005                 :             : static void
    1006                 :    23176880 : df_lr_confluence_0 (basic_block bb)
    1007                 :             : {
    1008                 :    23176880 :   bitmap op1 = &df_lr_get_bb_info (bb->index)->out;
    1009                 :    23176880 :   if (bb != EXIT_BLOCK_PTR_FOR_FN (cfun))
    1010                 :    10641878 :     bitmap_copy (op1, &df->hardware_regs_used);
    1011                 :    23176880 : }
    1012                 :             : 
    1013                 :             : 
    1014                 :             : /* Confluence function that ignores fake edges.  */
    1015                 :             : 
    1016                 :             : static bool
    1017                 :   457623472 : df_lr_confluence_n (edge e)
    1018                 :             : {
    1019                 :   457623472 :   bitmap op1 = &df_lr_get_bb_info (e->src->index)->out;
    1020                 :   457623472 :   bitmap op2 = &df_lr_get_bb_info (e->dest->index)->in;
    1021                 :   457623472 :   bool changed = false;
    1022                 :             : 
    1023                 :             :   /* Call-clobbered registers die across exception and call edges.
    1024                 :             :      Conservatively treat partially-clobbered registers as surviving
    1025                 :             :      across the edges; they might or might not, depending on what
    1026                 :             :      mode they have.  */
    1027                 :             :   /* ??? Abnormal call edges ignored for the moment, as this gets
    1028                 :             :      confused by sibling call edges, which crashes reg-stack.  */
    1029                 :   457623472 :   if (e->flags & EDGE_EH)
    1030                 :             :     {
    1031                 :    20688876 :       bitmap_view<HARD_REG_SET> eh_kills (eh_edge_abi.full_reg_clobbers ());
    1032                 :    20688876 :       changed = bitmap_ior_and_compl_into (op1, op2, eh_kills);
    1033                 :             :     }
    1034                 :             :   else
    1035                 :   436934596 :     changed = bitmap_ior_into (op1, op2);
    1036                 :             : 
    1037                 :   457623472 :   changed |= bitmap_ior_into (op1, &df->hardware_regs_used);
    1038                 :   457623472 :   return changed;
    1039                 :             : }
    1040                 :             : 
    1041                 :             : 
    1042                 :             : /* Transfer function.  */
    1043                 :             : 
    1044                 :             : static bool
    1045                 :   322797948 : df_lr_transfer_function (int bb_index)
    1046                 :             : {
    1047                 :   322797948 :   class df_lr_bb_info *bb_info = df_lr_get_bb_info (bb_index);
    1048                 :   322797948 :   bitmap in = &bb_info->in;
    1049                 :   322797948 :   bitmap out = &bb_info->out;
    1050                 :   322797948 :   bitmap use = &bb_info->use;
    1051                 :   322797948 :   bitmap def = &bb_info->def;
    1052                 :             : 
    1053                 :   322797948 :   return bitmap_ior_and_compl (in, use, out, def);
    1054                 :             : }
    1055                 :             : 
    1056                 :             : 
    1057                 :             : /* Run the fast dce as a side effect of building LR.  */
    1058                 :             : 
    1059                 :             : static void
    1060                 :    13645285 : df_lr_finalize (bitmap all_blocks)
    1061                 :             : {
    1062                 :    13645285 :   df_lr->solutions_dirty = false;
    1063                 :    13645285 :   if (df->changeable_flags & DF_LR_RUN_DCE)
    1064                 :             :     {
    1065                 :     5313377 :       run_fast_df_dce ();
    1066                 :             : 
    1067                 :             :       /* If dce deletes some instructions, we need to recompute the lr
    1068                 :             :          solution before proceeding further.  The problem is that fast
    1069                 :             :          dce is a pessimestic dataflow algorithm.  In the case where
    1070                 :             :          it deletes a statement S inside of a loop, the uses inside of
    1071                 :             :          S may not be deleted from the dataflow solution because they
    1072                 :             :          were carried around the loop.  While it is conservatively
    1073                 :             :          correct to leave these extra bits, the standards of df
    1074                 :             :          require that we maintain the best possible (least fixed
    1075                 :             :          point) solution.  The only way to do that is to redo the
    1076                 :             :          iteration from the beginning.  See PR35805 for an
    1077                 :             :          example.  */
    1078                 :     5313377 :       if (df_lr->solutions_dirty)
    1079                 :             :         {
    1080                 :      569955 :           df_clear_flags (DF_LR_RUN_DCE);
    1081                 :      569955 :           df_lr_alloc (all_blocks);
    1082                 :      569955 :           df_lr_local_compute (all_blocks);
    1083                 :      569955 :           df_worklist_dataflow (df_lr, all_blocks, df->postorder, df->n_blocks);
    1084                 :      569955 :           df_lr_finalize (all_blocks);
    1085                 :      569955 :           df_set_flags (DF_LR_RUN_DCE);
    1086                 :             :         }
    1087                 :             :     }
    1088                 :    13645285 : }
    1089                 :             : 
    1090                 :             : 
    1091                 :             : /* Free all storage associated with the problem.  */
    1092                 :             : 
    1093                 :             : static void
    1094                 :     1426767 : df_lr_free (void)
    1095                 :             : {
    1096                 :     1426767 :   struct df_lr_problem_data *problem_data
    1097                 :     1426767 :     = (struct df_lr_problem_data *) df_lr->problem_data;
    1098                 :     1426767 :   if (df_lr->block_info)
    1099                 :             :     {
    1100                 :             : 
    1101                 :     1426765 :       df_lr->block_info_size = 0;
    1102                 :     1426765 :       free (df_lr->block_info);
    1103                 :     1426765 :       df_lr->block_info = NULL;
    1104                 :     1426765 :       bitmap_obstack_release (&problem_data->lr_bitmaps);
    1105                 :     1426765 :       free (df_lr->problem_data);
    1106                 :     1426765 :       df_lr->problem_data = NULL;
    1107                 :             :     }
    1108                 :             : 
    1109                 :     1426767 :   BITMAP_FREE (df_lr->out_of_date_transfer_functions);
    1110                 :     1426767 :   free (df_lr);
    1111                 :     1426767 : }
    1112                 :             : 
    1113                 :             : 
    1114                 :             : /* Debugging info at top of bb.  */
    1115                 :             : 
    1116                 :             : static void
    1117                 :        4778 : df_lr_top_dump (basic_block bb, FILE *file)
    1118                 :             : {
    1119                 :        4778 :   class df_lr_bb_info *bb_info = df_lr_get_bb_info (bb->index);
    1120                 :        4682 :   struct df_lr_problem_data *problem_data;
    1121                 :        4682 :   if (!bb_info)
    1122                 :             :     return;
    1123                 :             : 
    1124                 :        4682 :   fprintf (file, ";; lr  in  \t");
    1125                 :        4682 :   df_print_regset (file, &bb_info->in);
    1126                 :        4682 :   if (df_lr->problem_data)
    1127                 :             :     {
    1128                 :        4682 :       problem_data = (struct df_lr_problem_data *)df_lr->problem_data;
    1129                 :        4682 :       if (problem_data->in)
    1130                 :             :         {
    1131                 :           0 :           fprintf (file, ";;  old in  \t");
    1132                 :           0 :           df_print_regset (file, &problem_data->in[bb->index]);
    1133                 :             :         }
    1134                 :             :     }
    1135                 :        4682 :   fprintf (file, ";; lr  use \t");
    1136                 :        4682 :   df_print_regset (file, &bb_info->use);
    1137                 :        4682 :   fprintf (file, ";; lr  def \t");
    1138                 :        4682 :   df_print_regset (file, &bb_info->def);
    1139                 :             : }
    1140                 :             : 
    1141                 :             : 
    1142                 :             : /* Debugging info at bottom of bb.  */
    1143                 :             : 
    1144                 :             : static void
    1145                 :        4778 : df_lr_bottom_dump (basic_block bb, FILE *file)
    1146                 :             : {
    1147                 :        4778 :   class df_lr_bb_info *bb_info = df_lr_get_bb_info (bb->index);
    1148                 :        4682 :   struct df_lr_problem_data *problem_data;
    1149                 :        4682 :   if (!bb_info)
    1150                 :             :     return;
    1151                 :             : 
    1152                 :        4682 :   fprintf (file, ";; lr  out \t");
    1153                 :        4682 :   df_print_regset (file, &bb_info->out);
    1154                 :        4682 :   if (df_lr->problem_data)
    1155                 :             :     {
    1156                 :        4682 :       problem_data = (struct df_lr_problem_data *)df_lr->problem_data;
    1157                 :        4682 :       if (problem_data->out)
    1158                 :             :         {
    1159                 :           0 :           fprintf (file, ";;  old out  \t");
    1160                 :           0 :           df_print_regset (file, &problem_data->out[bb->index]);
    1161                 :             :         }
    1162                 :             :     }
    1163                 :             : }
    1164                 :             : 
    1165                 :             : 
    1166                 :             : /* Build the datastructure to verify that the solution to the dataflow
    1167                 :             :    equations is not dirty.  */
    1168                 :             : 
    1169                 :             : static void
    1170                 :           0 : df_lr_verify_solution_start (void)
    1171                 :             : {
    1172                 :           0 :   basic_block bb;
    1173                 :           0 :   struct df_lr_problem_data *problem_data;
    1174                 :           0 :   if (df_lr->solutions_dirty)
    1175                 :             :     return;
    1176                 :             : 
    1177                 :             :   /* Set it true so that the solution is recomputed.  */
    1178                 :           0 :   df_lr->solutions_dirty = true;
    1179                 :             : 
    1180                 :           0 :   problem_data = (struct df_lr_problem_data *)df_lr->problem_data;
    1181                 :           0 :   problem_data->in = XNEWVEC (bitmap_head, last_basic_block_for_fn (cfun));
    1182                 :           0 :   problem_data->out = XNEWVEC (bitmap_head, last_basic_block_for_fn (cfun));
    1183                 :             : 
    1184                 :           0 :   FOR_ALL_BB_FN (bb, cfun)
    1185                 :             :     {
    1186                 :           0 :       bitmap_initialize (&problem_data->in[bb->index], &problem_data->lr_bitmaps);
    1187                 :           0 :       bitmap_initialize (&problem_data->out[bb->index], &problem_data->lr_bitmaps);
    1188                 :           0 :       bitmap_copy (&problem_data->in[bb->index], DF_LR_IN (bb));
    1189                 :           0 :       bitmap_copy (&problem_data->out[bb->index], DF_LR_OUT (bb));
    1190                 :             :     }
    1191                 :             : }
    1192                 :             : 
    1193                 :             : 
    1194                 :             : /* Compare the saved datastructure and the new solution to the dataflow
    1195                 :             :    equations.  */
    1196                 :             : 
    1197                 :             : static void
    1198                 :           0 : df_lr_verify_solution_end (void)
    1199                 :             : {
    1200                 :           0 :   struct df_lr_problem_data *problem_data;
    1201                 :           0 :   basic_block bb;
    1202                 :             : 
    1203                 :           0 :   problem_data = (struct df_lr_problem_data *)df_lr->problem_data;
    1204                 :             : 
    1205                 :           0 :   if (!problem_data->out)
    1206                 :             :     return;
    1207                 :             : 
    1208                 :           0 :   if (df_lr->solutions_dirty)
    1209                 :             :     /* Do not check if the solution is still dirty.  See the comment
    1210                 :             :        in df_lr_finalize for details.  */
    1211                 :           0 :     df_lr->solutions_dirty = false;
    1212                 :             :   else
    1213                 :           0 :     FOR_ALL_BB_FN (bb, cfun)
    1214                 :             :       {
    1215                 :           0 :         if ((!bitmap_equal_p (&problem_data->in[bb->index], DF_LR_IN (bb)))
    1216                 :           0 :             || (!bitmap_equal_p (&problem_data->out[bb->index], DF_LR_OUT (bb))))
    1217                 :             :           {
    1218                 :             :             /*df_dump (stderr);*/
    1219                 :           0 :             gcc_unreachable ();
    1220                 :             :           }
    1221                 :             :       }
    1222                 :             : 
    1223                 :             :   /* Cannot delete them immediately because you may want to dump them
    1224                 :             :      if the comparison fails.  */
    1225                 :           0 :   FOR_ALL_BB_FN (bb, cfun)
    1226                 :             :     {
    1227                 :           0 :       bitmap_clear (&problem_data->in[bb->index]);
    1228                 :           0 :       bitmap_clear (&problem_data->out[bb->index]);
    1229                 :             :     }
    1230                 :             : 
    1231                 :           0 :   free (problem_data->in);
    1232                 :           0 :   free (problem_data->out);
    1233                 :           0 :   problem_data->in = NULL;
    1234                 :           0 :   problem_data->out = NULL;
    1235                 :             : }
    1236                 :             : 
    1237                 :             : 
    1238                 :             : /* All of the information associated with every instance of the problem.  */
    1239                 :             : 
    1240                 :             : static const struct df_problem problem_LR =
    1241                 :             : {
    1242                 :             :   DF_LR,                      /* Problem id.  */
    1243                 :             :   DF_BACKWARD,                /* Direction.  */
    1244                 :             :   df_lr_alloc,                /* Allocate the problem specific data.  */
    1245                 :             :   df_lr_reset,                /* Reset global information.  */
    1246                 :             :   df_lr_free_bb_info,         /* Free basic block info.  */
    1247                 :             :   df_lr_local_compute,        /* Local compute function.  */
    1248                 :             :   df_lr_init,                 /* Init the solution specific data.  */
    1249                 :             :   df_worklist_dataflow,       /* Worklist solver.  */
    1250                 :             :   df_lr_confluence_0,         /* Confluence operator 0.  */
    1251                 :             :   df_lr_confluence_n,         /* Confluence operator n.  */
    1252                 :             :   df_lr_transfer_function,    /* Transfer function.  */
    1253                 :             :   df_lr_finalize,             /* Finalize function.  */
    1254                 :             :   df_lr_free,                 /* Free all of the problem information.  */
    1255                 :             :   NULL,                       /* Remove this problem from the stack of dataflow problems.  */
    1256                 :             :   NULL,                       /* Debugging.  */
    1257                 :             :   df_lr_top_dump,             /* Debugging start block.  */
    1258                 :             :   df_lr_bottom_dump,          /* Debugging end block.  */
    1259                 :             :   NULL,                       /* Debugging start insn.  */
    1260                 :             :   NULL,                       /* Debugging end insn.  */
    1261                 :             :   df_lr_verify_solution_start,/* Incremental solution verify start.  */
    1262                 :             :   df_lr_verify_solution_end,  /* Incremental solution verify end.  */
    1263                 :             :   NULL,                       /* Dependent problem.  */
    1264                 :             :   sizeof (class df_lr_bb_info),/* Size of entry of block_info array.  */
    1265                 :             :   TV_DF_LR,                   /* Timing variable.  */
    1266                 :             :   false                       /* Reset blocks on dropping out of blocks_to_analyze.  */
    1267                 :             : };
    1268                 :             : 
    1269                 :             : 
    1270                 :             : /* Create a new DATAFLOW instance and add it to an existing instance
    1271                 :             :    of DF.  The returned structure is what is used to get at the
    1272                 :             :    solution.  */
    1273                 :             : 
    1274                 :             : void
    1275                 :     1426767 : df_lr_add_problem (void)
    1276                 :             : {
    1277                 :     1426767 :   df_add_problem (&problem_LR);
    1278                 :             :   /* These will be initialized when df_scan_blocks processes each
    1279                 :             :      block.  */
    1280                 :     1426767 :   df_lr->out_of_date_transfer_functions = BITMAP_ALLOC (&df_bitmap_obstack);
    1281                 :     1426767 : }
    1282                 :             : 
    1283                 :             : 
    1284                 :             : /* Verify that all of the lr related info is consistent and
    1285                 :             :    correct.  */
    1286                 :             : 
    1287                 :             : void
    1288                 :           0 : df_lr_verify_transfer_functions (void)
    1289                 :             : {
    1290                 :           0 :   basic_block bb;
    1291                 :           0 :   bitmap_head saved_def;
    1292                 :           0 :   bitmap_head saved_use;
    1293                 :           0 :   bitmap_head all_blocks;
    1294                 :             : 
    1295                 :           0 :   if (!df)
    1296                 :           0 :     return;
    1297                 :             : 
    1298                 :           0 :   bitmap_initialize (&saved_def, &bitmap_default_obstack); 
    1299                 :           0 :   bitmap_initialize (&saved_use, &bitmap_default_obstack);
    1300                 :           0 :   bitmap_initialize (&all_blocks, &bitmap_default_obstack);
    1301                 :             : 
    1302                 :           0 :   FOR_ALL_BB_FN (bb, cfun)
    1303                 :             :     {
    1304                 :           0 :       class df_lr_bb_info *bb_info = df_lr_get_bb_info (bb->index);
    1305                 :           0 :       bitmap_set_bit (&all_blocks, bb->index);
    1306                 :             : 
    1307                 :           0 :       if (bb_info)
    1308                 :             :         {
    1309                 :             :           /* Make a copy of the transfer functions and then compute
    1310                 :             :              new ones to see if the transfer functions have
    1311                 :             :              changed.  */
    1312                 :           0 :           if (!bitmap_bit_p (df_lr->out_of_date_transfer_functions,
    1313                 :             :                              bb->index))
    1314                 :             :             {
    1315                 :           0 :               bitmap_copy (&saved_def, &bb_info->def);
    1316                 :           0 :               bitmap_copy (&saved_use, &bb_info->use);
    1317                 :           0 :               bitmap_clear (&bb_info->def);
    1318                 :           0 :               bitmap_clear (&bb_info->use);
    1319                 :             : 
    1320                 :           0 :               df_lr_bb_local_compute (bb->index);
    1321                 :           0 :               gcc_assert (bitmap_equal_p (&saved_def, &bb_info->def));
    1322                 :           0 :               gcc_assert (bitmap_equal_p (&saved_use, &bb_info->use));
    1323                 :             :             }
    1324                 :             :         }
    1325                 :             :       else
    1326                 :             :         {
    1327                 :             :           /* If we do not have basic block info, the block must be in
    1328                 :             :              the list of dirty blocks or else some one has added a
    1329                 :             :              block behind our backs. */
    1330                 :           0 :           gcc_assert (bitmap_bit_p (df_lr->out_of_date_transfer_functions,
    1331                 :             :                                     bb->index));
    1332                 :             :         }
    1333                 :             :       /* Make sure no one created a block without following
    1334                 :             :          procedures.  */
    1335                 :           0 :       gcc_assert (df_scan_get_bb_info (bb->index));
    1336                 :             :     }
    1337                 :             : 
    1338                 :             :   /* Make sure there are no dirty bits in blocks that have been deleted.  */
    1339                 :           0 :   gcc_assert (!bitmap_intersect_compl_p (df_lr->out_of_date_transfer_functions,
    1340                 :             :                                          &all_blocks));
    1341                 :             : 
    1342                 :           0 :   bitmap_clear (&saved_def);
    1343                 :           0 :   bitmap_clear (&saved_use);
    1344                 :           0 :   bitmap_clear (&all_blocks);
    1345                 :             : }
    1346                 :             : 
    1347                 :             : 
    1348                 :             : 
    1349                 :             : /*----------------------------------------------------------------------------
    1350                 :             :    LIVE AND MAY-INITIALIZED REGISTERS.
    1351                 :             : 
    1352                 :             :    This problem first computes the IN and OUT bitvectors for the
    1353                 :             :    may-initialized registers problems, which is a forward problem.
    1354                 :             :    It gives the set of registers for which we MAY have an available
    1355                 :             :    definition, i.e. for which there is an available definition on
    1356                 :             :    at least one path from the entry block to the entry/exit of a
    1357                 :             :    basic block.  Sets generate a definition, while clobbers kill
    1358                 :             :    a definition.
    1359                 :             : 
    1360                 :             :    In and out bitvectors are built for each basic block and are indexed by
    1361                 :             :    regnum (see df.h for details).  In and out bitvectors in struct
    1362                 :             :    df_live_bb_info actually refers to the may-initialized problem;
    1363                 :             : 
    1364                 :             :    Then, the in and out sets for the LIVE problem itself are computed.
    1365                 :             :    These are the logical AND of the IN and OUT sets from the LR problem
    1366                 :             :    and the may-initialized problem.
    1367                 :             : ----------------------------------------------------------------------------*/
    1368                 :             : 
    1369                 :             : /* Private data used to verify the solution for this problem.  */
    1370                 :             : struct df_live_problem_data
    1371                 :             : {
    1372                 :             :   bitmap_head *in;
    1373                 :             :   bitmap_head *out;
    1374                 :             :   /* An obstack for the bitmaps we need for this problem.  */
    1375                 :             :   bitmap_obstack live_bitmaps;
    1376                 :             : };
    1377                 :             : 
    1378                 :             : /* Scratch var used by transfer functions.  This is used to implement
    1379                 :             :    an optimization to reduce the amount of space used to compute the
    1380                 :             :    combined lr and live analysis.  */
    1381                 :             : static bitmap_head df_live_scratch;
    1382                 :             : 
    1383                 :             : 
    1384                 :             : /* Free basic block info.  */
    1385                 :             : 
    1386                 :             : static void
    1387                 :     5478936 : df_live_free_bb_info (basic_block bb ATTRIBUTE_UNUSED,
    1388                 :             :                     void *vbb_info)
    1389                 :             : {
    1390                 :     5478936 :   class df_live_bb_info *bb_info = (class df_live_bb_info *) vbb_info;
    1391                 :     5478936 :   if (bb_info)
    1392                 :             :     {
    1393                 :     5478936 :       bitmap_clear (&bb_info->gen);
    1394                 :     5478936 :       bitmap_clear (&bb_info->kill);
    1395                 :     5478936 :       bitmap_clear (&bb_info->in);
    1396                 :     5478936 :       bitmap_clear (&bb_info->out);
    1397                 :             :     }
    1398                 :     5478936 : }
    1399                 :             : 
    1400                 :             : 
    1401                 :             : /* Allocate or reset bitmaps for DF_LIVE blocks. The solution bits are
    1402                 :             :    not touched unless the block is new.  */
    1403                 :             : 
    1404                 :             : static void
    1405                 :    11439141 : df_live_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
    1406                 :             : {
    1407                 :    11439141 :   unsigned int bb_index;
    1408                 :    11439141 :   bitmap_iterator bi;
    1409                 :    11439141 :   struct df_live_problem_data *problem_data;
    1410                 :             : 
    1411                 :    11439141 :   if (df_live->problem_data)
    1412                 :             :     problem_data = (struct df_live_problem_data *) df_live->problem_data;
    1413                 :             :   else
    1414                 :             :     {
    1415                 :     2126086 :       problem_data = XNEW (struct df_live_problem_data);
    1416                 :     2126086 :       df_live->problem_data = problem_data;
    1417                 :             : 
    1418                 :     2126086 :       problem_data->out = NULL;
    1419                 :     2126086 :       problem_data->in = NULL;
    1420                 :     2126086 :       bitmap_obstack_initialize (&problem_data->live_bitmaps);
    1421                 :     2126086 :       bitmap_initialize (&df_live_scratch, &problem_data->live_bitmaps);
    1422                 :             :     }
    1423                 :             : 
    1424                 :    11439141 :   df_grow_bb_info (df_live);
    1425                 :             : 
    1426                 :    82394348 :   EXECUTE_IF_SET_IN_BITMAP (df_live->out_of_date_transfer_functions, 0, bb_index, bi)
    1427                 :             :     {
    1428                 :    70955207 :       class df_live_bb_info *bb_info = df_live_get_bb_info (bb_index);
    1429                 :             :       
    1430                 :             :       /* When bitmaps are already initialized, just clear them.  */
    1431                 :    70955207 :       if (bb_info->kill.obstack)
    1432                 :             :         {
    1433                 :    41398516 :           bitmap_clear (&bb_info->kill);
    1434                 :    41398516 :           bitmap_clear (&bb_info->gen);
    1435                 :             :         }
    1436                 :             :       else
    1437                 :             :         {
    1438                 :    29556691 :           bitmap_initialize (&bb_info->kill, &problem_data->live_bitmaps);
    1439                 :    29556691 :           bitmap_initialize (&bb_info->gen, &problem_data->live_bitmaps);
    1440                 :    29556691 :           bitmap_initialize (&bb_info->in, &problem_data->live_bitmaps);
    1441                 :    29556691 :           bitmap_initialize (&bb_info->out, &problem_data->live_bitmaps);
    1442                 :             :         }
    1443                 :             :     }
    1444                 :    11439141 :   df_live->optional_p = (optimize <= 1);
    1445                 :    11439141 : }
    1446                 :             : 
    1447                 :             : 
    1448                 :             : /* Reset the global solution for recalculation.  */
    1449                 :             : 
    1450                 :             : static void
    1451                 :       23267 : df_live_reset (bitmap all_blocks)
    1452                 :             : {
    1453                 :       23267 :   unsigned int bb_index;
    1454                 :       23267 :   bitmap_iterator bi;
    1455                 :             : 
    1456                 :      136624 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
    1457                 :             :     {
    1458                 :      113357 :       class df_live_bb_info *bb_info = df_live_get_bb_info (bb_index);
    1459                 :      113357 :       gcc_assert (bb_info);
    1460                 :      113357 :       bitmap_clear (&bb_info->in);
    1461                 :      113357 :       bitmap_clear (&bb_info->out);
    1462                 :             :     }
    1463                 :       23267 : }
    1464                 :             : 
    1465                 :             : 
    1466                 :             : /* Compute local uninitialized register info for basic block BB.  */
    1467                 :             : 
    1468                 :             : static void
    1469                 :    70955207 : df_live_bb_local_compute (unsigned int bb_index)
    1470                 :             : {
    1471                 :    70955207 :   basic_block bb = BASIC_BLOCK_FOR_FN (cfun, bb_index);
    1472                 :    70955207 :   class df_live_bb_info *bb_info = df_live_get_bb_info (bb_index);
    1473                 :    70955207 :   rtx_insn *insn;
    1474                 :    70955207 :   df_ref def;
    1475                 :    70955207 :   int luid = 0;
    1476                 :             : 
    1477                 :   950499052 :   FOR_BB_INSNS (bb, insn)
    1478                 :             :     {
    1479                 :   879543845 :       unsigned int uid = INSN_UID (insn);
    1480                 :   879543845 :       struct df_insn_info *insn_info = DF_INSN_UID_GET (uid);
    1481                 :             : 
    1482                 :             :       /* Inserting labels does not always trigger the incremental
    1483                 :             :          rescanning.  */
    1484                 :   879543845 :       if (!insn_info)
    1485                 :             :         {
    1486                 :    12047485 :           gcc_assert (!INSN_P (insn));
    1487                 :    12047485 :           insn_info = df_insn_create_insn_record (insn);
    1488                 :             :         }
    1489                 :             : 
    1490                 :   879543845 :       DF_INSN_INFO_LUID (insn_info) = luid;
    1491                 :   879543845 :       if (!INSN_P (insn))
    1492                 :   128651218 :         continue;
    1493                 :             : 
    1494                 :   750892627 :       luid++;
    1495                 :  3759376681 :       FOR_EACH_INSN_INFO_DEF (def, insn_info)
    1496                 :             :         {
    1497                 :  3008484054 :           unsigned int regno = DF_REF_REGNO (def);
    1498                 :             : 
    1499                 :  3008484054 :           if (DF_REF_FLAGS_IS_SET (def,
    1500                 :             :                                    DF_REF_PARTIAL | DF_REF_CONDITIONAL))
    1501                 :             :             /* All partial or conditional def
    1502                 :             :                seen are included in the gen set. */
    1503                 :     1643027 :             bitmap_set_bit (&bb_info->gen, regno);
    1504                 :  3006841027 :           else if (DF_REF_FLAGS_IS_SET (def, DF_REF_MUST_CLOBBER))
    1505                 :             :             /* Only must clobbers for the entire reg destroy the
    1506                 :             :                value.  */
    1507                 :    67866129 :             bitmap_set_bit (&bb_info->kill, regno);
    1508                 :  2938974898 :           else if (! DF_REF_FLAGS_IS_SET (def, DF_REF_MAY_CLOBBER))
    1509                 :   340713842 :             bitmap_set_bit (&bb_info->gen, regno);
    1510                 :             :         }
    1511                 :             :     }
    1512                 :             : 
    1513                 :   190993056 :   FOR_EACH_ARTIFICIAL_DEF (def, bb_index)
    1514                 :    49082642 :     bitmap_set_bit (&bb_info->gen, DF_REF_REGNO (def));
    1515                 :    70955207 : }
    1516                 :             : 
    1517                 :             : 
    1518                 :             : /* Compute local uninitialized register info.  */
    1519                 :             : 
    1520                 :             : static void
    1521                 :    11439141 : df_live_local_compute (bitmap all_blocks ATTRIBUTE_UNUSED)
    1522                 :             : {
    1523                 :    11439141 :   unsigned int bb_index;
    1524                 :    11439141 :   bitmap_iterator bi;
    1525                 :             : 
    1526                 :    11439141 :   df_grow_insn_info ();
    1527                 :             : 
    1528                 :    82394348 :   EXECUTE_IF_SET_IN_BITMAP (df_live->out_of_date_transfer_functions,
    1529                 :             :                             0, bb_index, bi)
    1530                 :             :     {
    1531                 :    70955207 :       df_live_bb_local_compute (bb_index);
    1532                 :             :     }
    1533                 :             : 
    1534                 :    11439141 :   bitmap_clear (df_live->out_of_date_transfer_functions);
    1535                 :    11439141 : }
    1536                 :             : 
    1537                 :             : 
    1538                 :             : /* Initialize the solution vectors.  */
    1539                 :             : 
    1540                 :             : static void
    1541                 :    11439141 : df_live_init (bitmap all_blocks)
    1542                 :             : {
    1543                 :    11439141 :   unsigned int bb_index;
    1544                 :    11439141 :   bitmap_iterator bi;
    1545                 :             : 
    1546                 :   238724504 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
    1547                 :             :     {
    1548                 :   227285363 :       class df_live_bb_info *bb_info = df_live_get_bb_info (bb_index);
    1549                 :   227285363 :       class df_lr_bb_info *bb_lr_info = df_lr_get_bb_info (bb_index);
    1550                 :             : 
    1551                 :             :       /* No register may reach a location where it is not used.  Thus
    1552                 :             :          we trim the rr result to the places where it is used.  */
    1553                 :   227285363 :       bitmap_and (&bb_info->out, &bb_info->gen, &bb_lr_info->out);
    1554                 :   227285363 :       bitmap_clear (&bb_info->in);
    1555                 :             :     }
    1556                 :    11439141 : }
    1557                 :             : 
    1558                 :             : /* Forward confluence function that ignores fake edges.  */
    1559                 :             : 
    1560                 :             : static bool
    1561                 :   342417906 : df_live_confluence_n (edge e)
    1562                 :             : {
    1563                 :   342417906 :   bitmap op1 = &df_live_get_bb_info (e->dest->index)->in;
    1564                 :   342417906 :   bitmap op2 = &df_live_get_bb_info (e->src->index)->out;
    1565                 :             : 
    1566                 :   342417906 :   if (e->flags & EDGE_FAKE)
    1567                 :             :     return false;
    1568                 :             : 
    1569                 :   342167822 :   return bitmap_ior_into (op1, op2);
    1570                 :             : }
    1571                 :             : 
    1572                 :             : 
    1573                 :             : /* Transfer function for the forwards may-initialized problem.  */
    1574                 :             : 
    1575                 :             : static bool
    1576                 :   239500036 : df_live_transfer_function (int bb_index)
    1577                 :             : {
    1578                 :   239500036 :   class df_live_bb_info *bb_info = df_live_get_bb_info (bb_index);
    1579                 :   239500036 :   class df_lr_bb_info *bb_lr_info = df_lr_get_bb_info (bb_index);
    1580                 :   239500036 :   bitmap in = &bb_info->in;
    1581                 :   239500036 :   bitmap out = &bb_info->out;
    1582                 :   239500036 :   bitmap gen = &bb_info->gen;
    1583                 :   239500036 :   bitmap kill = &bb_info->kill;
    1584                 :             : 
    1585                 :             :   /* We need to use a scratch set here so that the value returned from this
    1586                 :             :      function invocation properly reflects whether the sets changed in a
    1587                 :             :      significant way; i.e. not just because the lr set was anded in.  */
    1588                 :   239500036 :   bitmap_and (&df_live_scratch, gen, &bb_lr_info->out);
    1589                 :             :   /* No register may reach a location where it is not used.  Thus
    1590                 :             :      we trim the rr result to the places where it is used.  */
    1591                 :   239500036 :   bitmap_and_into (in, &bb_lr_info->in);
    1592                 :             : 
    1593                 :   239500036 :   return bitmap_ior_and_compl (out, &df_live_scratch, in, kill);
    1594                 :             : }
    1595                 :             : 
    1596                 :             : 
    1597                 :             : /* And the LR info with the may-initialized registers to produce the LIVE info.  */
    1598                 :             : 
    1599                 :             : static void
    1600                 :    11439141 : df_live_finalize (bitmap all_blocks)
    1601                 :             : {
    1602                 :             : 
    1603                 :    11439141 :   if (df_live->solutions_dirty)
    1604                 :             :     {
    1605                 :    11439141 :       bitmap_iterator bi;
    1606                 :    11439141 :       unsigned int bb_index;
    1607                 :             : 
    1608                 :   238724504 :       EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
    1609                 :             :         {
    1610                 :   227285363 :           class df_lr_bb_info *bb_lr_info = df_lr_get_bb_info (bb_index);
    1611                 :   227285363 :           class df_live_bb_info *bb_live_info = df_live_get_bb_info (bb_index);
    1612                 :             : 
    1613                 :             :           /* No register may reach a location where it is not used.  Thus
    1614                 :             :              we trim the rr result to the places where it is used.  */
    1615                 :   227285363 :           bitmap_and_into (&bb_live_info->in, &bb_lr_info->in);
    1616                 :   227285363 :           bitmap_and_into (&bb_live_info->out, &bb_lr_info->out);
    1617                 :             :         }
    1618                 :             : 
    1619                 :    11439141 :       df_live->solutions_dirty = false;
    1620                 :             :     }
    1621                 :    11439141 : }
    1622                 :             : 
    1623                 :             : 
    1624                 :             : /* Free all storage associated with the problem.  */
    1625                 :             : 
    1626                 :             : static void
    1627                 :     2128500 : df_live_free (void)
    1628                 :             : {
    1629                 :     2128500 :   struct df_live_problem_data *problem_data
    1630                 :     2128500 :     = (struct df_live_problem_data *) df_live->problem_data;
    1631                 :     2128500 :   if (df_live->block_info)
    1632                 :             :     {
    1633                 :     2126086 :       df_live->block_info_size = 0;
    1634                 :     2126086 :       free (df_live->block_info);
    1635                 :     2126086 :       df_live->block_info = NULL;
    1636                 :     2126086 :       bitmap_release (&df_live_scratch);
    1637                 :     2126086 :       bitmap_obstack_release (&problem_data->live_bitmaps);
    1638                 :     2126086 :       free (problem_data);
    1639                 :     2126086 :       df_live->problem_data = NULL;
    1640                 :             :     }
    1641                 :     2128500 :   BITMAP_FREE (df_live->out_of_date_transfer_functions);
    1642                 :     2128500 :   free (df_live);
    1643                 :     2128500 : }
    1644                 :             : 
    1645                 :             : 
    1646                 :             : /* Debugging info at top of bb.  */
    1647                 :             : 
    1648                 :             : static void
    1649                 :        3661 : df_live_top_dump (basic_block bb, FILE *file)
    1650                 :             : {
    1651                 :        3661 :   class df_live_bb_info *bb_info = df_live_get_bb_info (bb->index);
    1652                 :        3565 :   struct df_live_problem_data *problem_data;
    1653                 :             : 
    1654                 :        3565 :   if (!bb_info)
    1655                 :             :     return;
    1656                 :             : 
    1657                 :        3565 :   fprintf (file, ";; live  in  \t");
    1658                 :        3565 :   df_print_regset (file, &bb_info->in);
    1659                 :        3565 :   if (df_live->problem_data)
    1660                 :             :     {
    1661                 :        3565 :       problem_data = (struct df_live_problem_data *)df_live->problem_data;
    1662                 :        3565 :       if (problem_data->in)
    1663                 :             :         {
    1664                 :           0 :           fprintf (file, ";;  old in  \t");
    1665                 :           0 :           df_print_regset (file, &problem_data->in[bb->index]);
    1666                 :             :         }
    1667                 :             :     }
    1668                 :        3565 :   fprintf (file, ";; live  gen \t");
    1669                 :        3565 :   df_print_regset (file, &bb_info->gen);
    1670                 :        3565 :   fprintf (file, ";; live  kill\t");
    1671                 :        3565 :   df_print_regset (file, &bb_info->kill);
    1672                 :             : }
    1673                 :             : 
    1674                 :             : 
    1675                 :             : /* Debugging info at bottom of bb.  */
    1676                 :             : 
    1677                 :             : static void
    1678                 :        3661 : df_live_bottom_dump (basic_block bb, FILE *file)
    1679                 :             : {
    1680                 :        3661 :   class df_live_bb_info *bb_info = df_live_get_bb_info (bb->index);
    1681                 :        3565 :   struct df_live_problem_data *problem_data;
    1682                 :             : 
    1683                 :        3565 :   if (!bb_info)
    1684                 :             :     return;
    1685                 :             : 
    1686                 :        3565 :   fprintf (file, ";; live  out \t");
    1687                 :        3565 :   df_print_regset (file, &bb_info->out);
    1688                 :        3565 :   if (df_live->problem_data)
    1689                 :             :     {
    1690                 :        3565 :       problem_data = (struct df_live_problem_data *)df_live->problem_data;
    1691                 :        3565 :       if (problem_data->out)
    1692                 :             :         {
    1693                 :           0 :           fprintf (file, ";;  old out  \t");
    1694                 :           0 :           df_print_regset (file, &problem_data->out[bb->index]);
    1695                 :             :         }
    1696                 :             :     }
    1697                 :             : }
    1698                 :             : 
    1699                 :             : 
    1700                 :             : /* Build the datastructure to verify that the solution to the dataflow
    1701                 :             :    equations is not dirty.  */
    1702                 :             : 
    1703                 :             : static void
    1704                 :           0 : df_live_verify_solution_start (void)
    1705                 :             : {
    1706                 :           0 :   basic_block bb;
    1707                 :           0 :   struct df_live_problem_data *problem_data;
    1708                 :           0 :   if (df_live->solutions_dirty)
    1709                 :             :     return;
    1710                 :             : 
    1711                 :             :   /* Set it true so that the solution is recomputed.  */
    1712                 :           0 :   df_live->solutions_dirty = true;
    1713                 :             : 
    1714                 :           0 :   problem_data = (struct df_live_problem_data *)df_live->problem_data;
    1715                 :           0 :   problem_data->in = XNEWVEC (bitmap_head, last_basic_block_for_fn (cfun));
    1716                 :           0 :   problem_data->out = XNEWVEC (bitmap_head, last_basic_block_for_fn (cfun));
    1717                 :             : 
    1718                 :           0 :   FOR_ALL_BB_FN (bb, cfun)
    1719                 :             :     {
    1720                 :           0 :       bitmap_initialize (&problem_data->in[bb->index], &problem_data->live_bitmaps);
    1721                 :           0 :       bitmap_initialize (&problem_data->out[bb->index], &problem_data->live_bitmaps);
    1722                 :           0 :       bitmap_copy (&problem_data->in[bb->index], DF_LIVE_IN (bb));
    1723                 :           0 :       bitmap_copy (&problem_data->out[bb->index], DF_LIVE_OUT (bb));
    1724                 :             :     }
    1725                 :             : }
    1726                 :             : 
    1727                 :             : 
    1728                 :             : /* Compare the saved datastructure and the new solution to the dataflow
    1729                 :             :    equations.  */
    1730                 :             : 
    1731                 :             : static void
    1732                 :           0 : df_live_verify_solution_end (void)
    1733                 :             : {
    1734                 :           0 :   struct df_live_problem_data *problem_data;
    1735                 :           0 :   basic_block bb;
    1736                 :             : 
    1737                 :           0 :   problem_data = (struct df_live_problem_data *)df_live->problem_data;
    1738                 :           0 :   if (!problem_data->out)
    1739                 :             :     return;
    1740                 :             : 
    1741                 :           0 :   FOR_ALL_BB_FN (bb, cfun)
    1742                 :             :     {
    1743                 :           0 :       if ((!bitmap_equal_p (&problem_data->in[bb->index], DF_LIVE_IN (bb)))
    1744                 :           0 :           || (!bitmap_equal_p (&problem_data->out[bb->index], DF_LIVE_OUT (bb))))
    1745                 :             :         {
    1746                 :             :           /*df_dump (stderr);*/
    1747                 :           0 :           gcc_unreachable ();
    1748                 :             :         }
    1749                 :             :     }
    1750                 :             : 
    1751                 :             :   /* Cannot delete them immediately because you may want to dump them
    1752                 :             :      if the comparison fails.  */
    1753                 :           0 :   FOR_ALL_BB_FN (bb, cfun)
    1754                 :             :     {
    1755                 :           0 :       bitmap_clear (&problem_data->in[bb->index]);
    1756                 :           0 :       bitmap_clear (&problem_data->out[bb->index]);
    1757                 :             :     }
    1758                 :             : 
    1759                 :           0 :   free (problem_data->in);
    1760                 :           0 :   free (problem_data->out);
    1761                 :           0 :   free (problem_data);
    1762                 :           0 :   df_live->problem_data = NULL;
    1763                 :             : }
    1764                 :             : 
    1765                 :             : 
    1766                 :             : /* All of the information associated with every instance of the problem.  */
    1767                 :             : 
    1768                 :             : static const struct df_problem problem_LIVE =
    1769                 :             : {
    1770                 :             :   DF_LIVE,                      /* Problem id.  */
    1771                 :             :   DF_FORWARD,                   /* Direction.  */
    1772                 :             :   df_live_alloc,                /* Allocate the problem specific data.  */
    1773                 :             :   df_live_reset,                /* Reset global information.  */
    1774                 :             :   df_live_free_bb_info,         /* Free basic block info.  */
    1775                 :             :   df_live_local_compute,        /* Local compute function.  */
    1776                 :             :   df_live_init,                 /* Init the solution specific data.  */
    1777                 :             :   df_worklist_dataflow,         /* Worklist solver.  */
    1778                 :             :   NULL,                         /* Confluence operator 0.  */
    1779                 :             :   df_live_confluence_n,         /* Confluence operator n.  */
    1780                 :             :   df_live_transfer_function,    /* Transfer function.  */
    1781                 :             :   df_live_finalize,             /* Finalize function.  */
    1782                 :             :   df_live_free,                 /* Free all of the problem information.  */
    1783                 :             :   df_live_free,                 /* Remove this problem from the stack of dataflow problems.  */
    1784                 :             :   NULL,                         /* Debugging.  */
    1785                 :             :   df_live_top_dump,             /* Debugging start block.  */
    1786                 :             :   df_live_bottom_dump,          /* Debugging end block.  */
    1787                 :             :   NULL,                         /* Debugging start insn.  */
    1788                 :             :   NULL,                         /* Debugging end insn.  */
    1789                 :             :   df_live_verify_solution_start,/* Incremental solution verify start.  */
    1790                 :             :   df_live_verify_solution_end,  /* Incremental solution verify end.  */
    1791                 :             :   &problem_LR,                  /* Dependent problem.  */
    1792                 :             :   sizeof (class df_live_bb_info),/* Size of entry of block_info array.  */
    1793                 :             :   TV_DF_LIVE,                   /* Timing variable.  */
    1794                 :             :   false                         /* Reset blocks on dropping out of blocks_to_analyze.  */
    1795                 :             : };
    1796                 :             : 
    1797                 :             : 
    1798                 :             : /* Create a new DATAFLOW instance and add it to an existing instance
    1799                 :             :    of DF.  The returned structure is what is used to get at the
    1800                 :             :    solution.  */
    1801                 :             : 
    1802                 :             : void
    1803                 :     2128500 : df_live_add_problem (void)
    1804                 :             : {
    1805                 :     2128500 :   df_add_problem (&problem_LIVE);
    1806                 :             :   /* These will be initialized when df_scan_blocks processes each
    1807                 :             :      block.  */
    1808                 :     2128500 :   df_live->out_of_date_transfer_functions = BITMAP_ALLOC (&df_bitmap_obstack);
    1809                 :     2128500 : }
    1810                 :             : 
    1811                 :             : 
    1812                 :             : /* Set all of the blocks as dirty.  This needs to be done if this
    1813                 :             :    problem is added after all of the insns have been scanned.  */
    1814                 :             : 
    1815                 :             : void
    1816                 :     1422349 : df_live_set_all_dirty (void)
    1817                 :             : {
    1818                 :     1422349 :   basic_block bb;
    1819                 :    21918801 :   FOR_ALL_BB_FN (bb, cfun)
    1820                 :    20496452 :     bitmap_set_bit (df_live->out_of_date_transfer_functions,
    1821                 :             :                     bb->index);
    1822                 :     1422349 : }
    1823                 :             : 
    1824                 :             : 
    1825                 :             : /* Verify that all of the lr related info is consistent and
    1826                 :             :    correct.  */
    1827                 :             : 
    1828                 :             : void
    1829                 :           0 : df_live_verify_transfer_functions (void)
    1830                 :             : {
    1831                 :           0 :   basic_block bb;
    1832                 :           0 :   bitmap_head saved_gen;
    1833                 :           0 :   bitmap_head saved_kill;
    1834                 :           0 :   bitmap_head all_blocks;
    1835                 :             : 
    1836                 :           0 :   if (!df)
    1837                 :           0 :     return;
    1838                 :             : 
    1839                 :           0 :   bitmap_initialize (&saved_gen, &bitmap_default_obstack);
    1840                 :           0 :   bitmap_initialize (&saved_kill, &bitmap_default_obstack);
    1841                 :           0 :   bitmap_initialize (&all_blocks, &bitmap_default_obstack);
    1842                 :             : 
    1843                 :           0 :   df_grow_insn_info ();
    1844                 :             : 
    1845                 :           0 :   FOR_ALL_BB_FN (bb, cfun)
    1846                 :             :     {
    1847                 :           0 :       class df_live_bb_info *bb_info = df_live_get_bb_info (bb->index);
    1848                 :           0 :       bitmap_set_bit (&all_blocks, bb->index);
    1849                 :             : 
    1850                 :           0 :       if (bb_info)
    1851                 :             :         {
    1852                 :             :           /* Make a copy of the transfer functions and then compute
    1853                 :             :              new ones to see if the transfer functions have
    1854                 :             :              changed.  */
    1855                 :           0 :           if (!bitmap_bit_p (df_live->out_of_date_transfer_functions,
    1856                 :             :                              bb->index))
    1857                 :             :             {
    1858                 :           0 :               bitmap_copy (&saved_gen, &bb_info->gen);
    1859                 :           0 :               bitmap_copy (&saved_kill, &bb_info->kill);
    1860                 :           0 :               bitmap_clear (&bb_info->gen);
    1861                 :           0 :               bitmap_clear (&bb_info->kill);
    1862                 :             : 
    1863                 :           0 :               df_live_bb_local_compute (bb->index);
    1864                 :           0 :               gcc_assert (bitmap_equal_p (&saved_gen, &bb_info->gen));
    1865                 :           0 :               gcc_assert (bitmap_equal_p (&saved_kill, &bb_info->kill));
    1866                 :             :             }
    1867                 :             :         }
    1868                 :             :       else
    1869                 :             :         {
    1870                 :             :           /* If we do not have basic block info, the block must be in
    1871                 :             :              the list of dirty blocks or else some one has added a
    1872                 :             :              block behind our backs. */
    1873                 :           0 :           gcc_assert (bitmap_bit_p (df_live->out_of_date_transfer_functions,
    1874                 :             :                                     bb->index));
    1875                 :             :         }
    1876                 :             :       /* Make sure no one created a block without following
    1877                 :             :          procedures.  */
    1878                 :           0 :       gcc_assert (df_scan_get_bb_info (bb->index));
    1879                 :             :     }
    1880                 :             : 
    1881                 :             :   /* Make sure there are no dirty bits in blocks that have been deleted.  */
    1882                 :           0 :   gcc_assert (!bitmap_intersect_compl_p (df_live->out_of_date_transfer_functions,
    1883                 :             :                                          &all_blocks));
    1884                 :           0 :   bitmap_clear (&saved_gen);
    1885                 :           0 :   bitmap_clear (&saved_kill);
    1886                 :           0 :   bitmap_clear (&all_blocks);
    1887                 :             : }
    1888                 :             : 
    1889                 :             : /*----------------------------------------------------------------------------
    1890                 :             :    MUST-INITIALIZED REGISTERS.
    1891                 :             : ----------------------------------------------------------------------------*/
    1892                 :             : 
    1893                 :             : /* Private data used to verify the solution for this problem.  */
    1894                 :             : struct df_mir_problem_data
    1895                 :             : {
    1896                 :             :   bitmap_head *in;
    1897                 :             :   bitmap_head *out;
    1898                 :             :   /* An obstack for the bitmaps we need for this problem.  */
    1899                 :             :   bitmap_obstack mir_bitmaps;
    1900                 :             : };
    1901                 :             : 
    1902                 :             : 
    1903                 :             : /* Free basic block info.  */
    1904                 :             : 
    1905                 :             : static void
    1906                 :           0 : df_mir_free_bb_info (basic_block bb ATTRIBUTE_UNUSED,
    1907                 :             :                      void *vbb_info)
    1908                 :             : {
    1909                 :           0 :   class df_mir_bb_info *bb_info = (class df_mir_bb_info *) vbb_info;
    1910                 :           0 :   if (bb_info)
    1911                 :             :     {
    1912                 :           0 :       bitmap_clear (&bb_info->gen);
    1913                 :           0 :       bitmap_clear (&bb_info->kill);
    1914                 :           0 :       bitmap_clear (&bb_info->in);
    1915                 :           0 :       bitmap_clear (&bb_info->out);
    1916                 :             :     }
    1917                 :           0 : }
    1918                 :             : 
    1919                 :             : 
    1920                 :             : /* Allocate or reset bitmaps for DF_MIR blocks. The solution bits are
    1921                 :             :    not touched unless the block is new.  */
    1922                 :             : 
    1923                 :             : static void
    1924                 :      914381 : df_mir_alloc (bitmap all_blocks)
    1925                 :             : {
    1926                 :      914381 :   unsigned int bb_index;
    1927                 :      914381 :   bitmap_iterator bi;
    1928                 :      914381 :   struct df_mir_problem_data *problem_data;
    1929                 :             : 
    1930                 :      914381 :   if (df_mir->problem_data)
    1931                 :             :     problem_data = (struct df_mir_problem_data *) df_mir->problem_data;
    1932                 :             :   else
    1933                 :             :     {
    1934                 :      914381 :       problem_data = XNEW (struct df_mir_problem_data);
    1935                 :      914381 :       df_mir->problem_data = problem_data;
    1936                 :             : 
    1937                 :      914381 :       problem_data->out = NULL;
    1938                 :      914381 :       problem_data->in = NULL;
    1939                 :      914381 :       bitmap_obstack_initialize (&problem_data->mir_bitmaps);
    1940                 :             :     }
    1941                 :             : 
    1942                 :      914381 :   df_grow_bb_info (df_mir);
    1943                 :             : 
    1944                 :    12140373 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
    1945                 :             :     {
    1946                 :    11225992 :       class df_mir_bb_info *bb_info = df_mir_get_bb_info (bb_index);
    1947                 :             : 
    1948                 :             :       /* When bitmaps are already initialized, just clear them.  */
    1949                 :    11225992 :       if (bb_info->kill.obstack)
    1950                 :             :         {
    1951                 :           0 :           bitmap_clear (&bb_info->kill);
    1952                 :           0 :           bitmap_clear (&bb_info->gen);
    1953                 :             :         }
    1954                 :             :       else
    1955                 :             :         {
    1956                 :    11225992 :           bitmap_initialize (&bb_info->kill, &problem_data->mir_bitmaps);
    1957                 :    11225992 :           bitmap_initialize (&bb_info->gen, &problem_data->mir_bitmaps);
    1958                 :    11225992 :           bitmap_initialize (&bb_info->in, &problem_data->mir_bitmaps);
    1959                 :    11225992 :           bitmap_initialize (&bb_info->out, &problem_data->mir_bitmaps);
    1960                 :    11225992 :           bb_info->con_visited = false;
    1961                 :             :         }
    1962                 :             :     }
    1963                 :             : 
    1964                 :      914381 :   df_mir->optional_p = 1;
    1965                 :      914381 : }
    1966                 :             : 
    1967                 :             : 
    1968                 :             : /* Reset the global solution for recalculation.  */
    1969                 :             : 
    1970                 :             : static void
    1971                 :      914381 : df_mir_reset (bitmap all_blocks)
    1972                 :             : {
    1973                 :      914381 :   unsigned int bb_index;
    1974                 :      914381 :   bitmap_iterator bi;
    1975                 :             : 
    1976                 :    12140373 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
    1977                 :             :     {
    1978                 :    11225992 :       class df_mir_bb_info *bb_info = df_mir_get_bb_info (bb_index);
    1979                 :             : 
    1980                 :    11225992 :       gcc_assert (bb_info);
    1981                 :             : 
    1982                 :    11225992 :       bitmap_clear (&bb_info->in);
    1983                 :    11225992 :       bitmap_clear (&bb_info->out);
    1984                 :    11225992 :       bb_info->con_visited = false;
    1985                 :             :     }
    1986                 :      914381 : }
    1987                 :             : 
    1988                 :             : 
    1989                 :             : /* Compute local uninitialized register info for basic block BB.  */
    1990                 :             : 
    1991                 :             : static void
    1992                 :    11225992 : df_mir_bb_local_compute (unsigned int bb_index)
    1993                 :             : {
    1994                 :    11225992 :   basic_block bb = BASIC_BLOCK_FOR_FN (cfun, bb_index);
    1995                 :    11225992 :   class df_mir_bb_info *bb_info = df_mir_get_bb_info (bb_index);
    1996                 :    11225992 :   rtx_insn *insn;
    1997                 :    11225992 :   int luid = 0;
    1998                 :             : 
    1999                 :             :   /* Ignoring artificial defs is intentional: these often pretend that some
    2000                 :             :      registers carry incoming arguments (when they are FUNCTION_ARG_REGNO) even
    2001                 :             :      though they are not used for that.  As a result, conservatively assume
    2002                 :             :      they may be uninitialized.  */
    2003                 :             : 
    2004                 :   119547934 :   FOR_BB_INSNS (bb, insn)
    2005                 :             :     {
    2006                 :   108321942 :       unsigned int uid = INSN_UID (insn);
    2007                 :   108321942 :       struct df_insn_info *insn_info = DF_INSN_UID_GET (uid);
    2008                 :             : 
    2009                 :             :       /* Inserting labels does not always trigger the incremental
    2010                 :             :          rescanning.  */
    2011                 :   108321942 :       if (!insn_info)
    2012                 :             :         {
    2013                 :        3179 :           gcc_assert (!INSN_P (insn));
    2014                 :        3179 :           insn_info = df_insn_create_insn_record (insn);
    2015                 :             :         }
    2016                 :             : 
    2017                 :   108321942 :       DF_INSN_INFO_LUID (insn_info) = luid;
    2018                 :   108321942 :       if (!INSN_P (insn))
    2019                 :    19442495 :         continue;
    2020                 :             : 
    2021                 :    88879447 :       luid++;
    2022                 :    88879447 :       df_mir_simulate_one_insn (bb, insn, &bb_info->kill, &bb_info->gen);
    2023                 :             :     }
    2024                 :    11225992 : }
    2025                 :             : 
    2026                 :             : 
    2027                 :             : /* Compute local uninitialized register info.  */
    2028                 :             : 
    2029                 :             : static void
    2030                 :      914381 : df_mir_local_compute (bitmap all_blocks)
    2031                 :             : {
    2032                 :      914381 :   unsigned int bb_index;
    2033                 :      914381 :   bitmap_iterator bi;
    2034                 :             : 
    2035                 :      914381 :   df_grow_insn_info ();
    2036                 :             : 
    2037                 :    12140373 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
    2038                 :             :     {
    2039                 :    11225992 :       df_mir_bb_local_compute (bb_index);
    2040                 :             :     }
    2041                 :      914381 : }
    2042                 :             : 
    2043                 :             : 
    2044                 :             : /* Initialize the solution vectors.  */
    2045                 :             : 
    2046                 :             : static void
    2047                 :      914381 : df_mir_init (bitmap all_blocks)
    2048                 :             : {
    2049                 :      914381 :   df_mir_reset (all_blocks);
    2050                 :      914381 : }
    2051                 :             : 
    2052                 :             : 
    2053                 :             : /* Initialize IN sets for blocks with no predecessors: when landing on such
    2054                 :             :    blocks, assume all registers are uninitialized.  */
    2055                 :             : 
    2056                 :             : static void
    2057                 :      936755 : df_mir_confluence_0 (basic_block bb)
    2058                 :             : {
    2059                 :      936755 :   class df_mir_bb_info *bb_info = df_mir_get_bb_info (bb->index);
    2060                 :             : 
    2061                 :      936755 :   bitmap_clear (&bb_info->in);
    2062                 :      936755 :   bb_info->con_visited = true;
    2063                 :      936755 : }
    2064                 :             : 
    2065                 :             : 
    2066                 :             : /* Forward confluence function that ignores fake edges.  */
    2067                 :             : 
    2068                 :             : static bool
    2069                 :    15471557 : df_mir_confluence_n (edge e)
    2070                 :             : {
    2071                 :    15471557 :   if (e->flags & EDGE_FAKE)
    2072                 :             :     return false;
    2073                 :             : 
    2074                 :    15471557 :   df_mir_bb_info *src_info = df_mir_get_bb_info (e->src->index);
    2075                 :             :   /* If SRC was not visited yet then we'll and with all-ones which
    2076                 :             :      means no changes.  Do not consider DST con_visited by this
    2077                 :             :      operation alone either.  */
    2078                 :    15471557 :   if (!src_info->con_visited)
    2079                 :             :     return false;
    2080                 :             : 
    2081                 :    15001773 :   df_mir_bb_info *dst_info = df_mir_get_bb_info (e->dest->index);
    2082                 :    15001773 :   bitmap op1 = &dst_info->in;
    2083                 :    15001773 :   bitmap op2 = &src_info->out;
    2084                 :             :   /* If DEST was not visited yet just copy the SRC bitmap.  */
    2085                 :    15001773 :   if (!dst_info->con_visited)
    2086                 :             :     {
    2087                 :    10289237 :       dst_info->con_visited = true;
    2088                 :    10289237 :       bitmap_copy (op1, op2);
    2089                 :    10289237 :       return true;
    2090                 :             :     }
    2091                 :             : 
    2092                 :             :   /* A register is must-initialized at the entry of a basic block iff it is
    2093                 :             :      must-initialized at the exit of all the predecessors.  */
    2094                 :     4712536 :   return bitmap_and_into (op1, op2);
    2095                 :             : }
    2096                 :             : 
    2097                 :             : 
    2098                 :             : /* Transfer function for the forwards must-initialized problem.  */
    2099                 :             : 
    2100                 :             : static bool
    2101                 :    11573284 : df_mir_transfer_function (int bb_index)
    2102                 :             : {
    2103                 :    11573284 :   class df_mir_bb_info *bb_info = df_mir_get_bb_info (bb_index);
    2104                 :    11573284 :   bitmap in = &bb_info->in;
    2105                 :    11573284 :   bitmap out = &bb_info->out;
    2106                 :    11573284 :   bitmap gen = &bb_info->gen;
    2107                 :    11573284 :   bitmap kill = &bb_info->kill;
    2108                 :             : 
    2109                 :    11573284 :   return bitmap_ior_and_compl (out, gen, in, kill);
    2110                 :             : }
    2111                 :             : 
    2112                 :             : 
    2113                 :             : /* Free all storage associated with the problem.  */
    2114                 :             : 
    2115                 :             : static void
    2116                 :      914381 : df_mir_free (void)
    2117                 :             : {
    2118                 :      914381 :   struct df_mir_problem_data *problem_data
    2119                 :      914381 :     = (struct df_mir_problem_data *) df_mir->problem_data;
    2120                 :      914381 :   if (df_mir->block_info)
    2121                 :             :     {
    2122                 :      914381 :       df_mir->block_info_size = 0;
    2123                 :      914381 :       free (df_mir->block_info);
    2124                 :      914381 :       df_mir->block_info = NULL;
    2125                 :      914381 :       bitmap_obstack_release (&problem_data->mir_bitmaps);
    2126                 :      914381 :       free (problem_data);
    2127                 :      914381 :       df_mir->problem_data = NULL;
    2128                 :             :     }
    2129                 :      914381 :   free (df_mir);
    2130                 :      914381 : }
    2131                 :             : 
    2132                 :             : 
    2133                 :             : /* Debugging info at top of bb.  */
    2134                 :             : 
    2135                 :             : static void
    2136                 :           0 : df_mir_top_dump (basic_block bb, FILE *file)
    2137                 :             : {
    2138                 :           0 :   class df_mir_bb_info *bb_info = df_mir_get_bb_info (bb->index);
    2139                 :             : 
    2140                 :           0 :   if (!bb_info)
    2141                 :             :     return;
    2142                 :             : 
    2143                 :           0 :   fprintf (file, ";; mir   in  \t");
    2144                 :           0 :   df_print_regset (file, &bb_info->in);
    2145                 :           0 :   fprintf (file, ";; mir   kill\t");
    2146                 :           0 :   df_print_regset (file, &bb_info->kill);
    2147                 :           0 :   fprintf (file, ";; mir   gen \t");
    2148                 :           0 :   df_print_regset (file, &bb_info->gen);
    2149                 :             : }
    2150                 :             : 
    2151                 :             : /* Debugging info at bottom of bb.  */
    2152                 :             : 
    2153                 :             : static void
    2154                 :           0 : df_mir_bottom_dump (basic_block bb, FILE *file)
    2155                 :             : {
    2156                 :           0 :   class df_mir_bb_info *bb_info = df_mir_get_bb_info (bb->index);
    2157                 :             : 
    2158                 :           0 :   if (!bb_info)
    2159                 :             :     return;
    2160                 :             : 
    2161                 :           0 :   fprintf (file, ";; mir   out \t");
    2162                 :           0 :   df_print_regset (file, &bb_info->out);
    2163                 :             : }
    2164                 :             : 
    2165                 :             : 
    2166                 :             : /* Build the datastructure to verify that the solution to the dataflow
    2167                 :             :    equations is not dirty.  */
    2168                 :             : 
    2169                 :             : static void
    2170                 :           0 : df_mir_verify_solution_start (void)
    2171                 :             : {
    2172                 :           0 :   basic_block bb;
    2173                 :           0 :   struct df_mir_problem_data *problem_data;
    2174                 :           0 :   if (df_mir->solutions_dirty)
    2175                 :             :     return;
    2176                 :             : 
    2177                 :             :   /* Set it true so that the solution is recomputed.  */
    2178                 :           0 :   df_mir->solutions_dirty = true;
    2179                 :             : 
    2180                 :           0 :   problem_data = (struct df_mir_problem_data *) df_mir->problem_data;
    2181                 :           0 :   problem_data->in = XNEWVEC (bitmap_head, last_basic_block_for_fn (cfun));
    2182                 :           0 :   problem_data->out = XNEWVEC (bitmap_head, last_basic_block_for_fn (cfun));
    2183                 :           0 :   bitmap_obstack_initialize (&problem_data->mir_bitmaps);
    2184                 :             : 
    2185                 :           0 :   FOR_ALL_BB_FN (bb, cfun)
    2186                 :             :     {
    2187                 :           0 :       bitmap_initialize (&problem_data->in[bb->index], &problem_data->mir_bitmaps);
    2188                 :           0 :       bitmap_initialize (&problem_data->out[bb->index], &problem_data->mir_bitmaps);
    2189                 :           0 :       bitmap_copy (&problem_data->in[bb->index], DF_MIR_IN (bb));
    2190                 :           0 :       bitmap_copy (&problem_data->out[bb->index], DF_MIR_OUT (bb));
    2191                 :             :     }
    2192                 :             : }
    2193                 :             : 
    2194                 :             : 
    2195                 :             : /* Compare the saved datastructure and the new solution to the dataflow
    2196                 :             :    equations.  */
    2197                 :             : 
    2198                 :             : static void
    2199                 :           0 : df_mir_verify_solution_end (void)
    2200                 :             : {
    2201                 :           0 :   struct df_mir_problem_data *problem_data;
    2202                 :           0 :   basic_block bb;
    2203                 :             : 
    2204                 :           0 :   problem_data = (struct df_mir_problem_data *) df_mir->problem_data;
    2205                 :           0 :   if (!problem_data->out)
    2206                 :             :     return;
    2207                 :             : 
    2208                 :           0 :   FOR_ALL_BB_FN (bb, cfun)
    2209                 :             :     {
    2210                 :           0 :       if ((!bitmap_equal_p (&problem_data->in[bb->index], DF_MIR_IN (bb)))
    2211                 :           0 :           || (!bitmap_equal_p (&problem_data->out[bb->index], DF_MIR_OUT (bb))))
    2212                 :           0 :         gcc_unreachable ();
    2213                 :             :     }
    2214                 :             : 
    2215                 :             :   /* Cannot delete them immediately because you may want to dump them
    2216                 :             :      if the comparison fails.  */
    2217                 :           0 :   FOR_ALL_BB_FN (bb, cfun)
    2218                 :             :     {
    2219                 :           0 :       bitmap_clear (&problem_data->in[bb->index]);
    2220                 :           0 :       bitmap_clear (&problem_data->out[bb->index]);
    2221                 :             :     }
    2222                 :             : 
    2223                 :           0 :   free (problem_data->in);
    2224                 :           0 :   free (problem_data->out);
    2225                 :           0 :   bitmap_obstack_release (&problem_data->mir_bitmaps);
    2226                 :           0 :   free (problem_data);
    2227                 :           0 :   df_mir->problem_data = NULL;
    2228                 :             : }
    2229                 :             : 
    2230                 :             : 
    2231                 :             : /* All of the information associated with every instance of the problem.  */
    2232                 :             : 
    2233                 :             : static const struct df_problem problem_MIR =
    2234                 :             : {
    2235                 :             :   DF_MIR,                       /* Problem id.  */
    2236                 :             :   DF_FORWARD,                   /* Direction.  */
    2237                 :             :   df_mir_alloc,                 /* Allocate the problem specific data.  */
    2238                 :             :   df_mir_reset,                 /* Reset global information.  */
    2239                 :             :   df_mir_free_bb_info,          /* Free basic block info.  */
    2240                 :             :   df_mir_local_compute,         /* Local compute function.  */
    2241                 :             :   df_mir_init,                  /* Init the solution specific data.  */
    2242                 :             :   df_worklist_dataflow,         /* Worklist solver.  */
    2243                 :             :   df_mir_confluence_0,          /* Confluence operator 0.  */
    2244                 :             :   df_mir_confluence_n,          /* Confluence operator n.  */
    2245                 :             :   df_mir_transfer_function,     /* Transfer function.  */
    2246                 :             :   NULL,                         /* Finalize function.  */
    2247                 :             :   df_mir_free,                  /* Free all of the problem information.  */
    2248                 :             :   df_mir_free,                  /* Remove this problem from the stack of dataflow problems.  */
    2249                 :             :   NULL,                         /* Debugging.  */
    2250                 :             :   df_mir_top_dump,              /* Debugging start block.  */
    2251                 :             :   df_mir_bottom_dump,           /* Debugging end block.  */
    2252                 :             :   NULL,                         /* Debugging start insn.  */
    2253                 :             :   NULL,                         /* Debugging end insn.  */
    2254                 :             :   df_mir_verify_solution_start, /* Incremental solution verify start.  */
    2255                 :             :   df_mir_verify_solution_end,   /* Incremental solution verify end.  */
    2256                 :             :   NULL,                         /* Dependent problem.  */
    2257                 :             :   sizeof (class df_mir_bb_info),/* Size of entry of block_info array.  */
    2258                 :             :   TV_DF_MIR,                    /* Timing variable.  */
    2259                 :             :   false                         /* Reset blocks on dropping out of blocks_to_analyze.  */
    2260                 :             : };
    2261                 :             : 
    2262                 :             : 
    2263                 :             : /* Create a new DATAFLOW instance and add it to an existing instance
    2264                 :             :    of DF.  */
    2265                 :             : 
    2266                 :             : void
    2267                 :      914381 : df_mir_add_problem (void)
    2268                 :             : {
    2269                 :      914381 :   df_add_problem (&problem_MIR);
    2270                 :             :   /* These will be initialized when df_scan_blocks processes each
    2271                 :             :      block.  */
    2272                 :      914381 :   df_mir->out_of_date_transfer_functions = BITMAP_ALLOC (&df_bitmap_obstack);
    2273                 :      914381 : }
    2274                 :             : 
    2275                 :             : 
    2276                 :             : /* Apply the effects of the gen/kills in INSN to the corresponding bitmaps.  */
    2277                 :             : 
    2278                 :             : void
    2279                 :   139440576 : df_mir_simulate_one_insn (basic_block bb ATTRIBUTE_UNUSED, rtx_insn *insn,
    2280                 :             :                           bitmap kill, bitmap gen)
    2281                 :             : {
    2282                 :   139440576 :   df_ref def;
    2283                 :             : 
    2284                 :   890191808 :   FOR_EACH_INSN_DEF (def, insn)
    2285                 :             :     {
    2286                 :   750751232 :       unsigned int regno = DF_REF_REGNO (def);
    2287                 :             : 
    2288                 :             :       /* The order of GENs/KILLs matters, so if this def clobbers a reg, any
    2289                 :             :          previous gen is irrelevant (and reciprocally).  Also, claim that a
    2290                 :             :          register is GEN only if it is in all cases.  */
    2291                 :   750751232 :       if (DF_REF_FLAGS_IS_SET (def, DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER))
    2292                 :             :         {
    2293                 :   680854356 :           bitmap_set_bit (kill, regno);
    2294                 :   680854356 :           bitmap_clear_bit (gen, regno);
    2295                 :             :         }
    2296                 :             :       /* In the worst case, partial and conditional defs can leave bits
    2297                 :             :          uninitialized, so assume they do not change anything.  */
    2298                 :    69896876 :       else if (!DF_REF_FLAGS_IS_SET (def, DF_REF_PARTIAL | DF_REF_CONDITIONAL))
    2299                 :             :         {
    2300                 :    69864834 :           bitmap_set_bit (gen, regno);
    2301                 :    69864834 :           bitmap_clear_bit (kill, regno);
    2302                 :             :         }
    2303                 :             :     }
    2304                 :   139440576 : }
    2305                 :             : 
    2306                 :             : /*----------------------------------------------------------------------------
    2307                 :             :    CREATE DEF_USE (DU) and / or USE_DEF (UD) CHAINS
    2308                 :             : 
    2309                 :             :    Link either the defs to the uses and / or the uses to the defs.
    2310                 :             : 
    2311                 :             :    These problems are set up like the other dataflow problems so that
    2312                 :             :    they nicely fit into the framework.  They are much simpler and only
    2313                 :             :    involve a single traversal of instructions and an examination of
    2314                 :             :    the reaching defs information (the dependent problem).
    2315                 :             : ----------------------------------------------------------------------------*/
    2316                 :             : 
    2317                 :             : #define df_chain_problem_p(FLAG) (((enum df_chain_flags)df_chain->local_flags)&(FLAG))
    2318                 :             : 
    2319                 :             : /* Create a du or ud chain from SRC to DST and link it into SRC.   */
    2320                 :             : 
    2321                 :             : struct df_link *
    2322                 :  1067527093 : df_chain_create (df_ref src, df_ref dst)
    2323                 :             : {
    2324                 :  1067527093 :   struct df_link *head = DF_REF_CHAIN (src);
    2325                 :  1067527093 :   struct df_link *link = df_chain->block_pool->allocate ();
    2326                 :             : 
    2327                 :  1067527093 :   DF_REF_CHAIN (src) = link;
    2328                 :  1067527093 :   link->next = head;
    2329                 :  1067527093 :   link->ref = dst;
    2330                 :  1067527093 :   return link;
    2331                 :             : }
    2332                 :             : 
    2333                 :             : 
    2334                 :             : /* Delete any du or ud chains that start at REF and point to
    2335                 :             :    TARGET.  */
    2336                 :             : static void
    2337                 :      749564 : df_chain_unlink_1 (df_ref ref, df_ref target)
    2338                 :             : {
    2339                 :      749564 :   struct df_link *chain = DF_REF_CHAIN (ref);
    2340                 :      749564 :   struct df_link *prev = NULL;
    2341                 :             : 
    2342                 :    27866360 :   while (chain)
    2343                 :             :     {
    2344                 :    27849742 :       if (chain->ref == target)
    2345                 :             :         {
    2346                 :      732946 :           if (prev)
    2347                 :      295052 :             prev->next = chain->next;
    2348                 :             :           else
    2349                 :      437894 :             DF_REF_CHAIN (ref) = chain->next;
    2350                 :      732946 :           df_chain->block_pool->remove (chain);
    2351                 :      732946 :           return;
    2352                 :             :         }
    2353                 :    27116796 :       prev = chain;
    2354                 :    27116796 :       chain = chain->next;
    2355                 :             :     }
    2356                 :             : }
    2357                 :             : 
    2358                 :             : 
    2359                 :             : /* Delete a du or ud chain that leave or point to REF.  */
    2360                 :             : 
    2361                 :             : void
    2362                 :      540379 : df_chain_unlink (df_ref ref)
    2363                 :             : {
    2364                 :      540379 :   struct df_link *chain = DF_REF_CHAIN (ref);
    2365                 :     1289943 :   while (chain)
    2366                 :             :     {
    2367                 :      749564 :       struct df_link *next = chain->next;
    2368                 :             :       /* Delete the other side if it exists.  */
    2369                 :      749564 :       df_chain_unlink_1 (chain->ref, ref);
    2370                 :      749564 :       df_chain->block_pool->remove (chain);
    2371                 :      749564 :       chain = next;
    2372                 :             :     }
    2373                 :      540379 :   DF_REF_CHAIN (ref) = NULL;
    2374                 :      540379 : }
    2375                 :             : 
    2376                 :             : 
    2377                 :             : /* Copy the du or ud chain starting at FROM_REF and attach it to
    2378                 :             :    TO_REF.  */
    2379                 :             : 
    2380                 :             : void
    2381                 :           0 : df_chain_copy (df_ref to_ref,
    2382                 :             :                struct df_link *from_ref)
    2383                 :             : {
    2384                 :           0 :   while (from_ref)
    2385                 :             :     {
    2386                 :           0 :       df_chain_create (to_ref, from_ref->ref);
    2387                 :           0 :       from_ref = from_ref->next;
    2388                 :             :     }
    2389                 :           0 : }
    2390                 :             : 
    2391                 :             : 
    2392                 :             : /* Remove this problem from the stack of dataflow problems.  */
    2393                 :             : 
    2394                 :             : static void
    2395                 :    11133658 : df_chain_remove_problem (void)
    2396                 :             : {
    2397                 :    11133658 :   bitmap_iterator bi;
    2398                 :    11133658 :   unsigned int bb_index;
    2399                 :             : 
    2400                 :             :   /* Wholesale destruction of the old chains.  */
    2401                 :    11133658 :   if (df_chain->block_pool)
    2402                 :     5566829 :     delete df_chain->block_pool;
    2403                 :             : 
    2404                 :    72301952 :   EXECUTE_IF_SET_IN_BITMAP (df_chain->out_of_date_transfer_functions, 0, bb_index, bi)
    2405                 :             :     {
    2406                 :    61168294 :       rtx_insn *insn;
    2407                 :    61168294 :       df_ref def, use;
    2408                 :    61168294 :       basic_block bb = BASIC_BLOCK_FOR_FN (cfun, bb_index);
    2409                 :             : 
    2410                 :    61168294 :       if (df_chain_problem_p (DF_DU_CHAIN))
    2411                 :   146358148 :         FOR_EACH_ARTIFICIAL_DEF (def, bb_index)
    2412                 :    61490022 :           DF_REF_CHAIN (def) = NULL;
    2413                 :    61168294 :       if (df_chain_problem_p (DF_UD_CHAIN))
    2414                 :   290625265 :         FOR_EACH_ARTIFICIAL_USE (use, bb_index)
    2415                 :   168288677 :           DF_REF_CHAIN (use) = NULL;
    2416                 :             : 
    2417                 :   656480712 :       FOR_BB_INSNS (bb, insn)
    2418                 :   595312418 :         if (INSN_P (insn))
    2419                 :             :           {
    2420                 :   497810520 :             df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
    2421                 :   497810520 :             if (df_chain_problem_p (DF_DU_CHAIN))
    2422                 :  1797561045 :               FOR_EACH_INSN_INFO_DEF (def, insn_info)
    2423                 :  1453237781 :                 DF_REF_CHAIN (def) = NULL;
    2424                 :   497810520 :             if (df_chain_problem_p (DF_UD_CHAIN))
    2425                 :             :               {
    2426                 :   904052679 :                 FOR_EACH_INSN_INFO_USE (use, insn_info)
    2427                 :   406242159 :                   DF_REF_CHAIN (use) = NULL;
    2428                 :   510768121 :                 FOR_EACH_INSN_INFO_EQ_USE (use, insn_info)
    2429                 :    12957601 :                   DF_REF_CHAIN (use) = NULL;
    2430                 :             :               }
    2431                 :             :           }
    2432                 :             :     }
    2433                 :             : 
    2434                 :    11133658 :   bitmap_clear (df_chain->out_of_date_transfer_functions);
    2435                 :    11133658 :   df_chain->block_pool = NULL;
    2436                 :    11133658 : }
    2437                 :             : 
    2438                 :             : 
    2439                 :             : /* Remove the chain problem completely.  */
    2440                 :             : 
    2441                 :             : static void
    2442                 :     5566829 : df_chain_fully_remove_problem (void)
    2443                 :             : {
    2444                 :     5566829 :   df_chain_remove_problem ();
    2445                 :     5566829 :   BITMAP_FREE (df_chain->out_of_date_transfer_functions);
    2446                 :     5566829 :   free (df_chain);
    2447                 :     5566829 : }
    2448                 :             : 
    2449                 :             : 
    2450                 :             : /* Create def-use or use-def chains.  */
    2451                 :             : 
    2452                 :             : static void
    2453                 :     5566829 : df_chain_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
    2454                 :             : {
    2455                 :     5566829 :   df_chain_remove_problem ();
    2456                 :     5566829 :   df_chain->block_pool = new object_allocator<df_link> ("df_chain_block pool");
    2457                 :     5566829 :   df_chain->optional_p = true;
    2458                 :     5566829 : }
    2459                 :             : 
    2460                 :             : 
    2461                 :             : /* Reset all of the chains when the set of basic blocks changes.  */
    2462                 :             : 
    2463                 :             : static void
    2464                 :           0 : df_chain_reset (bitmap blocks_to_clear ATTRIBUTE_UNUSED)
    2465                 :             : {
    2466                 :           0 :   df_chain_remove_problem ();
    2467                 :           0 : }
    2468                 :             : 
    2469                 :             : 
    2470                 :             : /* Create the chains for a list of USEs.  */
    2471                 :             : 
    2472                 :             : static void
    2473                 :   708863358 : df_chain_create_bb_process_use (bitmap local_rd,
    2474                 :             :                                 df_ref use,
    2475                 :             :                                 int top_flag)
    2476                 :             : {
    2477                 :   708863358 :   bitmap_iterator bi;
    2478                 :   708863358 :   unsigned int def_index;
    2479                 :             : 
    2480                 :  1281585362 :   for (; use; use = DF_REF_NEXT_LOC (use))
    2481                 :             :     {
    2482                 :   572722004 :       unsigned int uregno = DF_REF_REGNO (use);
    2483                 :   572722004 :       if ((!(df->changeable_flags & DF_NO_HARD_REGS))
    2484                 :     4562649 :           || (uregno >= FIRST_PSEUDO_REGISTER))
    2485                 :             :         {
    2486                 :             :           /* Do not want to go through this for an uninitialized var.  */
    2487                 :   571497364 :           int count = DF_DEFS_COUNT (uregno);
    2488                 :   571497364 :           if (count)
    2489                 :             :             {
    2490                 :   533244394 :               if (top_flag == (DF_REF_FLAGS (use) & DF_REF_AT_TOP))
    2491                 :             :                 {
    2492                 :   533244394 :                   unsigned int first_index = DF_DEFS_BEGIN (uregno);
    2493                 :   533244394 :                   unsigned int last_index = first_index + count - 1;
    2494                 :             : 
    2495                 :  1160472126 :                   EXECUTE_IF_SET_IN_BITMAP (local_rd, first_index, def_index, bi)
    2496                 :             :                     {
    2497                 :  1092841992 :                       df_ref def;
    2498                 :  1092841992 :                       if (def_index > last_index)
    2499                 :             :                         break;
    2500                 :             : 
    2501                 :   627227732 :                       def = DF_DEFS_GET (def_index);
    2502                 :   627227732 :                       if (df_chain_problem_p (DF_DU_CHAIN))
    2503                 :   440299361 :                         df_chain_create (def, use);
    2504                 :   627227732 :                       if (df_chain_problem_p (DF_UD_CHAIN))
    2505                 :   627227732 :                         df_chain_create (use, def);
    2506                 :             :                     }
    2507                 :             :                 }
    2508                 :             :             }
    2509                 :             :         }
    2510                 :             :     }
    2511                 :   708863358 : }
    2512                 :             : 
    2513                 :             : 
    2514                 :             : /* Create chains from reaching defs bitmaps for basic block BB.  */
    2515                 :             : 
    2516                 :             : static void
    2517                 :    60474277 : df_chain_create_bb (unsigned int bb_index)
    2518                 :             : {
    2519                 :    60474277 :   basic_block bb = BASIC_BLOCK_FOR_FN (cfun, bb_index);
    2520                 :    60474277 :   class df_rd_bb_info *bb_info = df_rd_get_bb_info (bb_index);
    2521                 :    60474277 :   rtx_insn *insn;
    2522                 :    60474277 :   bitmap_head cpy;
    2523                 :             : 
    2524                 :    60474277 :   bitmap_initialize (&cpy, &bitmap_default_obstack);
    2525                 :    60474277 :   bitmap_copy (&cpy, &bb_info->in);
    2526                 :    60474277 :   bitmap_set_bit (df_chain->out_of_date_transfer_functions, bb_index);
    2527                 :             : 
    2528                 :             :   /* Since we are going forwards, process the artificial uses first
    2529                 :             :      then the artificial defs second.  */
    2530                 :             : 
    2531                 :             : #ifdef EH_USES
    2532                 :             :   /* Create the chains for the artificial uses from the EH_USES at the
    2533                 :             :      beginning of the block.  */
    2534                 :             : 
    2535                 :             :   /* Artificials are only hard regs.  */
    2536                 :             :   if (!(df->changeable_flags & DF_NO_HARD_REGS))
    2537                 :             :     df_chain_create_bb_process_use (&cpy,
    2538                 :             :                                     df_get_artificial_uses (bb->index),
    2539                 :             :                                     DF_REF_AT_TOP);
    2540                 :             : #endif
    2541                 :             : 
    2542                 :    60474277 :   df_rd_simulate_artificial_defs_at_top (bb, &cpy);
    2543                 :             : 
    2544                 :             :   /* Process the regular instructions next.  */
    2545                 :   651383499 :   FOR_BB_INSNS (bb, insn)
    2546                 :   590909222 :     if (INSN_P (insn))
    2547                 :             :       {
    2548                 :   494399431 :         unsigned int uid = INSN_UID (insn);
    2549                 :             : 
    2550                 :             :         /* First scan the uses and link them up with the defs that remain
    2551                 :             :            in the cpy vector.  */
    2552                 :   494399431 :         df_chain_create_bb_process_use (&cpy, DF_INSN_UID_USES (uid), 0);
    2553                 :   494399431 :         if (df->changeable_flags & DF_EQ_NOTES)
    2554                 :   154476474 :           df_chain_create_bb_process_use (&cpy, DF_INSN_UID_EQ_USES (uid), 0);
    2555                 :             : 
    2556                 :             :         /* Since we are going forwards, process the defs second.  */
    2557                 :   494399431 :         df_rd_simulate_one_insn (bb, insn, &cpy);
    2558                 :             :       }
    2559                 :             : 
    2560                 :             :   /* Create the chains for the artificial uses of the hard registers
    2561                 :             :      at the end of the block.  */
    2562                 :    60474277 :   if (!(df->changeable_flags & DF_NO_HARD_REGS))
    2563                 :    59987453 :     df_chain_create_bb_process_use (&cpy,
    2564                 :    59987453 :                                     df_get_artificial_uses (bb->index),
    2565                 :             :                                     0);
    2566                 :             : 
    2567                 :    60474277 :   bitmap_clear (&cpy);
    2568                 :    60474277 : }
    2569                 :             : 
    2570                 :             : /* Create def-use chains from reaching use bitmaps for basic blocks
    2571                 :             :    in BLOCKS.  */
    2572                 :             : 
    2573                 :             : static void
    2574                 :     5566829 : df_chain_finalize (bitmap all_blocks)
    2575                 :             : {
    2576                 :     5566829 :   unsigned int bb_index;
    2577                 :     5566829 :   bitmap_iterator bi;
    2578                 :             : 
    2579                 :    66041106 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
    2580                 :             :     {
    2581                 :    60474277 :       df_chain_create_bb (bb_index);
    2582                 :             :     }
    2583                 :     5566829 : }
    2584                 :             : 
    2585                 :             : 
    2586                 :             : /* Free all storage associated with the problem.  */
    2587                 :             : 
    2588                 :             : static void
    2589                 :           0 : df_chain_free (void)
    2590                 :             : {
    2591                 :           0 :   delete df_chain->block_pool;
    2592                 :           0 :   BITMAP_FREE (df_chain->out_of_date_transfer_functions);
    2593                 :           0 :   free (df_chain);
    2594                 :           0 : }
    2595                 :             : 
    2596                 :             : 
    2597                 :             : /* Debugging info.  */
    2598                 :             : 
    2599                 :             : static void
    2600                 :        1342 : df_chain_bb_dump (basic_block bb, FILE *file, bool top)
    2601                 :             : {
    2602                 :             :   /* Artificials are only hard regs.  */
    2603                 :        1342 :   if (df->changeable_flags & DF_NO_HARD_REGS)
    2604                 :             :     return;
    2605                 :        1342 :   if (df_chain_problem_p (DF_UD_CHAIN))
    2606                 :             :     {
    2607                 :        1342 :       df_ref use;
    2608                 :             : 
    2609                 :        2013 :       fprintf (file,
    2610                 :             :                ";;  UD chains for artificial uses at %s\n",
    2611                 :             :                top ? "top" : "bottom");
    2612                 :        7876 :       FOR_EACH_ARTIFICIAL_USE (use, bb->index)
    2613                 :        5192 :         if ((top && (DF_REF_FLAGS (use) & DF_REF_AT_TOP))
    2614                 :        2596 :             || (!top && !(DF_REF_FLAGS (use) & DF_REF_AT_TOP)))
    2615                 :             :           {
    2616                 :        2596 :             fprintf (file, ";;   reg %d ", DF_REF_REGNO (use));
    2617                 :        2596 :             df_chain_dump (DF_REF_CHAIN (use), file);
    2618                 :        2596 :             fprintf (file, "\n");
    2619                 :             :           }
    2620                 :             :     }
    2621                 :        1342 :   if (df_chain_problem_p (DF_DU_CHAIN))
    2622                 :             :     {
    2623                 :           0 :       df_ref def;
    2624                 :             : 
    2625                 :           0 :       fprintf (file,
    2626                 :             :                ";;  DU chains for artificial defs at %s\n",
    2627                 :             :                top ? "top" : "bottom");
    2628                 :           0 :       FOR_EACH_ARTIFICIAL_DEF (def, bb->index)
    2629                 :           0 :         if ((top && (DF_REF_FLAGS (def) & DF_REF_AT_TOP))
    2630                 :           0 :             || (!top && !(DF_REF_FLAGS (def) & DF_REF_AT_TOP)))
    2631                 :             :           {
    2632                 :           0 :             fprintf (file, ";;   reg %d ", DF_REF_REGNO (def));
    2633                 :           0 :             df_chain_dump (DF_REF_CHAIN (def), file);
    2634                 :           0 :             fprintf (file, "\n");
    2635                 :             :           }
    2636                 :             :     }
    2637                 :             : }
    2638                 :             : 
    2639                 :             : static void
    2640                 :         671 : df_chain_top_dump (basic_block bb, FILE *file)
    2641                 :             : {
    2642                 :         671 :   df_chain_bb_dump (bb, file, /*top=*/true);
    2643                 :         671 : }
    2644                 :             : 
    2645                 :             : static void
    2646                 :         671 : df_chain_bottom_dump (basic_block bb, FILE *file)
    2647                 :             : {
    2648                 :         671 :   df_chain_bb_dump (bb, file, /*top=*/false);
    2649                 :         671 : }
    2650                 :             : 
    2651                 :             : static void
    2652                 :        2388 : df_chain_insn_top_dump (const rtx_insn *insn, FILE *file)
    2653                 :             : {
    2654                 :        2388 :   if (df_chain_problem_p (DF_UD_CHAIN) && INSN_P (insn))
    2655                 :             :     {
    2656                 :        1508 :       struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
    2657                 :        1508 :       df_ref use;
    2658                 :             : 
    2659                 :        1508 :       fprintf (file, ";;   UD chains for insn luid %d uid %d\n",
    2660                 :             :                DF_INSN_INFO_LUID (insn_info), INSN_UID (insn));
    2661                 :        3333 :       FOR_EACH_INSN_INFO_USE (use, insn_info)
    2662                 :        1825 :         if (!HARD_REGISTER_NUM_P (DF_REF_REGNO (use))
    2663                 :         584 :             || !(df->changeable_flags & DF_NO_HARD_REGS))
    2664                 :             :           {
    2665                 :        1825 :             fprintf (file, ";;      reg %d ", DF_REF_REGNO (use));
    2666                 :        1825 :             if (DF_REF_FLAGS (use) & DF_REF_READ_WRITE)
    2667                 :           0 :               fprintf (file, "read/write ");
    2668                 :        1825 :             df_chain_dump (DF_REF_CHAIN (use), file);
    2669                 :        1825 :             fprintf (file, "\n");
    2670                 :             :           }
    2671                 :        1580 :       FOR_EACH_INSN_INFO_EQ_USE (use, insn_info)
    2672                 :          72 :         if (!HARD_REGISTER_NUM_P (DF_REF_REGNO (use))
    2673                 :           9 :             || !(df->changeable_flags & DF_NO_HARD_REGS))
    2674                 :             :           {
    2675                 :          72 :             fprintf (file, ";;   eq_note reg %d ", DF_REF_REGNO (use));
    2676                 :          72 :             df_chain_dump (DF_REF_CHAIN (use), file);
    2677                 :          72 :             fprintf (file, "\n");
    2678                 :             :           }
    2679                 :             :     }
    2680                 :        2388 : }
    2681                 :             : 
    2682                 :             : static void
    2683                 :        2388 : df_chain_insn_bottom_dump (const rtx_insn *insn, FILE *file)
    2684                 :             : {
    2685                 :        2388 :   if (df_chain_problem_p (DF_DU_CHAIN) && INSN_P (insn))
    2686                 :             :     {
    2687                 :           0 :       struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
    2688                 :           0 :       df_ref def;
    2689                 :           0 :       fprintf (file, ";;   DU chains for insn luid %d uid %d\n",
    2690                 :             :                DF_INSN_INFO_LUID (insn_info), INSN_UID (insn));
    2691                 :           0 :       FOR_EACH_INSN_INFO_DEF (def, insn_info)
    2692                 :           0 :         if (!HARD_REGISTER_NUM_P (DF_REF_REGNO (def))
    2693                 :           0 :             || !(df->changeable_flags & DF_NO_HARD_REGS))
    2694                 :             :           {
    2695                 :           0 :             fprintf (file, ";;      reg %d ", DF_REF_REGNO (def));
    2696                 :           0 :             if (DF_REF_FLAGS (def) & DF_REF_READ_WRITE)
    2697                 :           0 :               fprintf (file, "read/write ");
    2698                 :           0 :             df_chain_dump (DF_REF_CHAIN (def), file);
    2699                 :           0 :             fprintf (file, "\n");
    2700                 :             :           }
    2701                 :           0 :       fprintf (file, "\n");
    2702                 :             :     }
    2703                 :        2388 : }
    2704                 :             : 
    2705                 :             : static const struct df_problem problem_CHAIN =
    2706                 :             : {
    2707                 :             :   DF_CHAIN,                   /* Problem id.  */
    2708                 :             :   DF_NONE,                    /* Direction.  */
    2709                 :             :   df_chain_alloc,             /* Allocate the problem specific data.  */
    2710                 :             :   df_chain_reset,             /* Reset global information.  */
    2711                 :             :   NULL,                       /* Free basic block info.  */
    2712                 :             :   NULL,                       /* Local compute function.  */
    2713                 :             :   NULL,                       /* Init the solution specific data.  */
    2714                 :             :   NULL,                       /* Iterative solver.  */
    2715                 :             :   NULL,                       /* Confluence operator 0.  */
    2716                 :             :   NULL,                       /* Confluence operator n.  */
    2717                 :             :   NULL,                       /* Transfer function.  */
    2718                 :             :   df_chain_finalize,          /* Finalize function.  */
    2719                 :             :   df_chain_free,              /* Free all of the problem information.  */
    2720                 :             :   df_chain_fully_remove_problem,/* Remove this problem from the stack of dataflow problems.  */
    2721                 :             :   NULL,                       /* Debugging.  */
    2722                 :             :   df_chain_top_dump,          /* Debugging start block.  */
    2723                 :             :   df_chain_bottom_dump,       /* Debugging end block.  */
    2724                 :             :   df_chain_insn_top_dump,     /* Debugging start insn.  */
    2725                 :             :   df_chain_insn_bottom_dump,  /* Debugging end insn.  */
    2726                 :             :   NULL,                       /* Incremental solution verify start.  */
    2727                 :             :   NULL,                       /* Incremental solution verify end.  */
    2728                 :             :   &problem_RD,                /* Dependent problem.  */
    2729                 :             :   sizeof (struct df_scan_bb_info),/* Size of entry of block_info array.  */
    2730                 :             :   TV_DF_CHAIN,                /* Timing variable.  */
    2731                 :             :   false                       /* Reset blocks on dropping out of blocks_to_analyze.  */
    2732                 :             : };
    2733                 :             : 
    2734                 :             : 
    2735                 :             : /* Create a new DATAFLOW instance and add it to an existing instance
    2736                 :             :    of DF.  The returned structure is what is used to get at the
    2737                 :             :    solution.  */
    2738                 :             : 
    2739                 :             : void
    2740                 :     5566829 : df_chain_add_problem (unsigned int chain_flags)
    2741                 :             : {
    2742                 :     5566829 :   df_add_problem (&problem_CHAIN);
    2743                 :     5566829 :   df_chain->local_flags = chain_flags;
    2744                 :     5566829 :   df_chain->out_of_date_transfer_functions = BITMAP_ALLOC (&df_bitmap_obstack);
    2745                 :     5566829 : }
    2746                 :             : 
    2747                 :             : #undef df_chain_problem_p
    2748                 :             : 
    2749                 :             : 
    2750                 :             : /*----------------------------------------------------------------------------
    2751                 :             :    WORD LEVEL LIVE REGISTERS
    2752                 :             : 
    2753                 :             :    Find the locations in the function where any use of a pseudo can
    2754                 :             :    reach in the backwards direction.  In and out bitvectors are built
    2755                 :             :    for each basic block.  We only track pseudo registers that have a
    2756                 :             :    size of 2 * UNITS_PER_WORD; bitmaps are indexed by 2 * regno and
    2757                 :             :    contain two bits corresponding to each of the subwords.
    2758                 :             : 
    2759                 :             :    ----------------------------------------------------------------------------*/
    2760                 :             : 
    2761                 :             : /* Private data used to verify the solution for this problem.  */
    2762                 :             : struct df_word_lr_problem_data
    2763                 :             : {
    2764                 :             :   /* An obstack for the bitmaps we need for this problem.  */
    2765                 :             :   bitmap_obstack word_lr_bitmaps;
    2766                 :             : };
    2767                 :             : 
    2768                 :             : 
    2769                 :             : /* Free basic block info.  */
    2770                 :             : 
    2771                 :             : static void
    2772                 :           0 : df_word_lr_free_bb_info (basic_block bb ATTRIBUTE_UNUSED,
    2773                 :             :                          void *vbb_info)
    2774                 :             : {
    2775                 :           0 :   class df_word_lr_bb_info *bb_info = (class df_word_lr_bb_info *) vbb_info;
    2776                 :           0 :   if (bb_info)
    2777                 :             :     {
    2778                 :           0 :       bitmap_clear (&bb_info->use);
    2779                 :           0 :       bitmap_clear (&bb_info->def);
    2780                 :           0 :       bitmap_clear (&bb_info->in);
    2781                 :           0 :       bitmap_clear (&bb_info->out);
    2782                 :             :     }
    2783                 :           0 : }
    2784                 :             : 
    2785                 :             : 
    2786                 :             : /* Allocate or reset bitmaps for DF_WORD_LR blocks. The solution bits are
    2787                 :             :    not touched unless the block is new.  */
    2788                 :             : 
    2789                 :             : static void
    2790                 :      147212 : df_word_lr_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
    2791                 :             : {
    2792                 :      147212 :   unsigned int bb_index;
    2793                 :      147212 :   bitmap_iterator bi;
    2794                 :      147212 :   basic_block bb;
    2795                 :      147212 :   struct df_word_lr_problem_data *problem_data
    2796                 :      147212 :     = XNEW (struct df_word_lr_problem_data);
    2797                 :             : 
    2798                 :      147212 :   df_word_lr->problem_data = problem_data;
    2799                 :             : 
    2800                 :      147212 :   df_grow_bb_info (df_word_lr);
    2801                 :             : 
    2802                 :             :   /* Create the mapping from regnos to slots. This does not change
    2803                 :             :      unless the problem is destroyed and recreated.  In particular, if
    2804                 :             :      we end up deleting the only insn that used a subreg, we do not
    2805                 :             :      want to redo the mapping because this would invalidate everything
    2806                 :             :      else.  */
    2807                 :             : 
    2808                 :      147212 :   bitmap_obstack_initialize (&problem_data->word_lr_bitmaps);
    2809                 :             : 
    2810                 :     3567971 :   FOR_EACH_BB_FN (bb, cfun)
    2811                 :     3420759 :     bitmap_set_bit (df_word_lr->out_of_date_transfer_functions, bb->index);
    2812                 :             : 
    2813                 :      147212 :   bitmap_set_bit (df_word_lr->out_of_date_transfer_functions, ENTRY_BLOCK);
    2814                 :      147212 :   bitmap_set_bit (df_word_lr->out_of_date_transfer_functions, EXIT_BLOCK);
    2815                 :             : 
    2816                 :     3862395 :   EXECUTE_IF_SET_IN_BITMAP (df_word_lr->out_of_date_transfer_functions, 0, bb_index, bi)
    2817                 :             :     {
    2818                 :     3715183 :       class df_word_lr_bb_info *bb_info = df_word_lr_get_bb_info (bb_index);
    2819                 :             :       
    2820                 :             :       /* When bitmaps are already initialized, just clear them.  */
    2821                 :     3715183 :       if (bb_info->use.obstack)
    2822                 :             :         {
    2823                 :          17 :           bitmap_clear (&bb_info->def);
    2824                 :          17 :           bitmap_clear (&bb_info->use);
    2825                 :             :         }
    2826                 :             :       else
    2827                 :             :         {
    2828                 :     3715166 :           bitmap_initialize (&bb_info->use, &problem_data->word_lr_bitmaps);
    2829                 :     3715166 :           bitmap_initialize (&bb_info->def, &problem_data->word_lr_bitmaps);
    2830                 :     3715166 :           bitmap_initialize (&bb_info->in, &problem_data->word_lr_bitmaps);
    2831                 :     3715166 :           bitmap_initialize (&bb_info->out, &problem_data->word_lr_bitmaps);
    2832                 :             :         }
    2833                 :             :     }
    2834                 :             : 
    2835                 :      147212 :   df_word_lr->optional_p = true;
    2836                 :      147212 : }
    2837                 :             : 
    2838                 :             : 
    2839                 :             : /* Reset the global solution for recalculation.  */
    2840                 :             : 
    2841                 :             : static void
    2842                 :           0 : df_word_lr_reset (bitmap all_blocks)
    2843                 :             : {
    2844                 :           0 :   unsigned int bb_index;
    2845                 :           0 :   bitmap_iterator bi;
    2846                 :             : 
    2847                 :           0 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
    2848                 :             :     {
    2849                 :           0 :       class df_word_lr_bb_info *bb_info = df_word_lr_get_bb_info (bb_index);
    2850                 :           0 :       gcc_assert (bb_info);
    2851                 :           0 :       bitmap_clear (&bb_info->in);
    2852                 :           0 :       bitmap_clear (&bb_info->out);
    2853                 :             :     }
    2854                 :           0 : }
    2855                 :             : 
    2856                 :             : /* Examine REF, and if it is for a reg we're interested in, set or
    2857                 :             :    clear the bits corresponding to its subwords from the bitmap
    2858                 :             :    according to IS_SET.  LIVE is the bitmap we should update.  We do
    2859                 :             :    not track hard regs or pseudos of any size other than 2 *
    2860                 :             :    UNITS_PER_WORD.
    2861                 :             :    We return true if we changed the bitmap, or if we encountered a register
    2862                 :             :    we're not tracking.  */
    2863                 :             : 
    2864                 :             : bool
    2865                 :   485625144 : df_word_lr_mark_ref (df_ref ref, bool is_set, regset live)
    2866                 :             : {
    2867                 :   485625144 :   rtx orig_reg = DF_REF_REG (ref);
    2868                 :   485625144 :   rtx reg = orig_reg;
    2869                 :   485625144 :   machine_mode reg_mode;
    2870                 :   485625144 :   unsigned regno;
    2871                 :             :   /* Left at -1 for whole accesses.  */
    2872                 :   485625144 :   int which_subword = -1;
    2873                 :   485625144 :   bool changed = false;
    2874                 :             : 
    2875                 :   485625144 :   if (GET_CODE (reg) == SUBREG)
    2876                 :     4068493 :     reg = SUBREG_REG (orig_reg);
    2877                 :   485625144 :   regno = REGNO (reg);
    2878                 :   485625144 :   reg_mode = GET_MODE (reg);
    2879                 :   485625144 :   if (regno < FIRST_PSEUDO_REGISTER
    2880                 :   553342494 :       || maybe_ne (GET_MODE_SIZE (reg_mode), 2 * UNITS_PER_WORD))
    2881                 :   475832572 :     return true;
    2882                 :             : 
    2883                 :     9792572 :   if (GET_CODE (orig_reg) == SUBREG
    2884                 :     9792572 :       && read_modify_subreg_p (orig_reg))
    2885                 :             :     {
    2886                 :     1498906 :       gcc_assert (DF_REF_FLAGS_IS_SET (ref, DF_REF_PARTIAL));
    2887                 :     1498906 :       if (subreg_lowpart_p (orig_reg))
    2888                 :             :         which_subword = 0;
    2889                 :             :       else
    2890                 :      707799 :         which_subword = 1;
    2891                 :             :     }
    2892                 :     9792572 :   if (is_set)
    2893                 :             :     {
    2894                 :     6253852 :       if (which_subword != 1)
    2895                 :     5761943 :         changed |= bitmap_set_bit (live, regno * 2);
    2896                 :     5761943 :       if (which_subword != 0)
    2897                 :     5731695 :         changed |= bitmap_set_bit (live, regno * 2 + 1);
    2898                 :             :     }
    2899                 :             :   else
    2900                 :             :     {
    2901                 :     3538720 :       if (which_subword != 1)
    2902                 :     3322830 :         changed |= bitmap_clear_bit (live, regno * 2);
    2903                 :     3322830 :       if (which_subword != 0)
    2904                 :     3269770 :         changed |= bitmap_clear_bit (live, regno * 2 + 1);
    2905                 :             :     }
    2906                 :             :   return changed;
    2907                 :             : }
    2908                 :             : 
    2909                 :             : /* Compute local live register info for basic block BB.  */
    2910                 :             : 
    2911                 :             : static void
    2912                 :     3567971 : df_word_lr_bb_local_compute (unsigned int bb_index)
    2913                 :             : {
    2914                 :     3567971 :   basic_block bb = BASIC_BLOCK_FOR_FN (cfun, bb_index);
    2915                 :     3567971 :   class df_word_lr_bb_info *bb_info = df_word_lr_get_bb_info (bb_index);
    2916                 :     3567971 :   rtx_insn *insn;
    2917                 :     3567971 :   df_ref def, use;
    2918                 :             : 
    2919                 :             :   /* Ensure that artificial refs don't contain references to pseudos.  */
    2920                 :     9720875 :   FOR_EACH_ARTIFICIAL_DEF (def, bb_index)
    2921                 :     2584933 :     gcc_assert (DF_REF_REGNO (def) < FIRST_PSEUDO_REGISTER);
    2922                 :             : 
    2923                 :    17251007 :   FOR_EACH_ARTIFICIAL_USE (use, bb_index)
    2924                 :    13683036 :     gcc_assert (DF_REF_REGNO (use) < FIRST_PSEUDO_REGISTER);
    2925                 :             : 
    2926                 :    42689377 :   FOR_BB_INSNS_REVERSE (bb, insn)
    2927                 :             :     {
    2928                 :    39121406 :       if (!NONDEBUG_INSN_P (insn))
    2929                 :    18539290 :         continue;
    2930                 :             : 
    2931                 :    20582116 :       df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
    2932                 :   165008287 :       FOR_EACH_INSN_INFO_DEF (def, insn_info)
    2933                 :             :         /* If the def is to only part of the reg, it does
    2934                 :             :            not kill the other defs that reach here.  */
    2935                 :   144426171 :         if (!(DF_REF_FLAGS (def) & (DF_REF_CONDITIONAL)))
    2936                 :             :           {
    2937                 :   144426171 :             df_word_lr_mark_ref (def, true, &bb_info->def);
    2938                 :   144426171 :             df_word_lr_mark_ref (def, false, &bb_info->use);
    2939                 :             :           }
    2940                 :    46764613 :       FOR_EACH_INSN_INFO_USE (use, insn_info)
    2941                 :    26182497 :         df_word_lr_mark_ref (use, true, &bb_info->use);
    2942                 :             :     }
    2943                 :     3567971 : }
    2944                 :             : 
    2945                 :             : 
    2946                 :             : /* Compute local live register info for each basic block within BLOCKS.  */
    2947                 :             : 
    2948                 :             : static void
    2949                 :      147212 : df_word_lr_local_compute (bitmap all_blocks ATTRIBUTE_UNUSED)
    2950                 :             : {
    2951                 :      147212 :   unsigned int bb_index;
    2952                 :      147212 :   bitmap_iterator bi;
    2953                 :             : 
    2954                 :     3862395 :   EXECUTE_IF_SET_IN_BITMAP (df_word_lr->out_of_date_transfer_functions, 0, bb_index, bi)
    2955                 :             :     {
    2956                 :     3715183 :       if (bb_index == EXIT_BLOCK)
    2957                 :             :         {
    2958                 :      147212 :           unsigned regno;
    2959                 :      147212 :           bitmap_iterator bi;
    2960                 :      147212 :           EXECUTE_IF_SET_IN_BITMAP (df->exit_block_uses, FIRST_PSEUDO_REGISTER,
    2961                 :             :                                     regno, bi)
    2962                 :           0 :             gcc_unreachable ();
    2963                 :             :         }
    2964                 :             :       else
    2965                 :     3567971 :         df_word_lr_bb_local_compute (bb_index);
    2966                 :             :     }
    2967                 :             : 
    2968                 :      147212 :   bitmap_clear (df_word_lr->out_of_date_transfer_functions);
    2969                 :      147212 : }
    2970                 :             : 
    2971                 :             : 
    2972                 :             : /* Initialize the solution vectors.  */
    2973                 :             : 
    2974                 :             : static void
    2975                 :      147212 : df_word_lr_init (bitmap all_blocks)
    2976                 :             : {
    2977                 :      147212 :   unsigned int bb_index;
    2978                 :      147212 :   bitmap_iterator bi;
    2979                 :             : 
    2980                 :     3862395 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
    2981                 :             :     {
    2982                 :     3715183 :       class df_word_lr_bb_info *bb_info = df_word_lr_get_bb_info (bb_index);
    2983                 :     3715183 :       bitmap_copy (&bb_info->in, &bb_info->use);
    2984                 :     3715183 :       bitmap_clear (&bb_info->out);
    2985                 :             :     }
    2986                 :      147212 : }
    2987                 :             : 
    2988                 :             : 
    2989                 :             : /* Confluence function that ignores fake edges.  */
    2990                 :             : 
    2991                 :             : static bool
    2992                 :     5678341 : df_word_lr_confluence_n (edge e)
    2993                 :             : {
    2994                 :     5678341 :   bitmap op1 = &df_word_lr_get_bb_info (e->src->index)->out;
    2995                 :     5678341 :   bitmap op2 = &df_word_lr_get_bb_info (e->dest->index)->in;
    2996                 :             : 
    2997                 :     5678341 :   return bitmap_ior_into (op1, op2);
    2998                 :             : }
    2999                 :             : 
    3000                 :             : 
    3001                 :             : /* Transfer function.  */
    3002                 :             : 
    3003                 :             : static bool
    3004                 :     4038510 : df_word_lr_transfer_function (int bb_index)
    3005                 :             : {
    3006                 :     4038510 :   class df_word_lr_bb_info *bb_info = df_word_lr_get_bb_info (bb_index);
    3007                 :     4038510 :   bitmap in = &bb_info->in;
    3008                 :     4038510 :   bitmap out = &bb_info->out;
    3009                 :     4038510 :   bitmap use = &bb_info->use;
    3010                 :     4038510 :   bitmap def = &bb_info->def;
    3011                 :             : 
    3012                 :     4038510 :   return bitmap_ior_and_compl (in, use, out, def);
    3013                 :             : }
    3014                 :             : 
    3015                 :             : 
    3016                 :             : /* Free all storage associated with the problem.  */
    3017                 :             : 
    3018                 :             : static void
    3019                 :      147211 : df_word_lr_free (void)
    3020                 :             : {
    3021                 :      147211 :   struct df_word_lr_problem_data *problem_data
    3022                 :      147211 :     = (struct df_word_lr_problem_data *)df_word_lr->problem_data;
    3023                 :             : 
    3024                 :      147211 :   if (df_word_lr->block_info)
    3025                 :             :     {
    3026                 :      147211 :       df_word_lr->block_info_size = 0;
    3027                 :      147211 :       free (df_word_lr->block_info);
    3028                 :      147211 :       df_word_lr->block_info = NULL;
    3029                 :             :     }
    3030                 :             : 
    3031                 :      147211 :   BITMAP_FREE (df_word_lr->out_of_date_transfer_functions);
    3032                 :      147211 :   bitmap_obstack_release (&problem_data->word_lr_bitmaps);
    3033                 :      147211 :   free (problem_data);
    3034                 :      147211 :   free (df_word_lr);
    3035                 :      147211 : }
    3036                 :             : 
    3037                 :             : 
    3038                 :             : /* Debugging info at top of bb.  */
    3039                 :             : 
    3040                 :             : static void
    3041                 :           0 : df_word_lr_top_dump (basic_block bb, FILE *file)
    3042                 :             : {
    3043                 :           0 :   class df_word_lr_bb_info *bb_info = df_word_lr_get_bb_info (bb->index);
    3044                 :           0 :   if (!bb_info)
    3045                 :             :     return;
    3046                 :             : 
    3047                 :           0 :   fprintf (file, ";; blr  in  \t");
    3048                 :           0 :   df_print_word_regset (file, &bb_info->in);
    3049                 :           0 :   fprintf (file, ";; blr  use \t");
    3050                 :           0 :   df_print_word_regset (file, &bb_info->use);
    3051                 :           0 :   fprintf (file, ";; blr  def \t");
    3052                 :           0 :   df_print_word_regset (file, &bb_info->def);
    3053                 :             : }
    3054                 :             : 
    3055                 :             : 
    3056                 :             : /* Debugging info at bottom of bb.  */
    3057                 :             : 
    3058                 :             : static void
    3059                 :           0 : df_word_lr_bottom_dump (basic_block bb, FILE *file)
    3060                 :             : {
    3061                 :           0 :   class df_word_lr_bb_info *bb_info = df_word_lr_get_bb_info (bb->index);
    3062                 :           0 :   if (!bb_info)
    3063                 :             :     return;
    3064                 :             : 
    3065                 :           0 :   fprintf (file, ";; blr  out \t");
    3066                 :           0 :   df_print_word_regset (file, &bb_info->out);
    3067                 :             : }
    3068                 :             : 
    3069                 :             : 
    3070                 :             : /* All of the information associated with every instance of the problem.  */
    3071                 :             : 
    3072                 :             : static const struct df_problem problem_WORD_LR =
    3073                 :             : {
    3074                 :             :   DF_WORD_LR,                      /* Problem id.  */
    3075                 :             :   DF_BACKWARD,                     /* Direction.  */
    3076                 :             :   df_word_lr_alloc,                /* Allocate the problem specific data.  */
    3077                 :             :   df_word_lr_reset,                /* Reset global information.  */
    3078                 :             :   df_word_lr_free_bb_info,         /* Free basic block info.  */
    3079                 :             :   df_word_lr_local_compute,        /* Local compute function.  */
    3080                 :             :   df_word_lr_init,                 /* Init the solution specific data.  */
    3081                 :             :   df_worklist_dataflow,            /* Worklist solver.  */
    3082                 :             :   NULL,                            /* Confluence operator 0.  */
    3083                 :             :   df_word_lr_confluence_n,         /* Confluence operator n.  */
    3084                 :             :   df_word_lr_transfer_function,    /* Transfer function.  */
    3085                 :             :   NULL,                            /* Finalize function.  */
    3086                 :             :   df_word_lr_free,                 /* Free all of the problem information.  */
    3087                 :             :   df_word_lr_free,                 /* Remove this problem from the stack of dataflow problems.  */
    3088                 :             :   NULL,                            /* Debugging.  */
    3089                 :             :   df_word_lr_top_dump,             /* Debugging start block.  */
    3090                 :             :   df_word_lr_bottom_dump,          /* Debugging end block.  */
    3091                 :             :   NULL,                            /* Debugging start insn.  */
    3092                 :             :   NULL,                            /* Debugging end insn.  */
    3093                 :             :   NULL,                            /* Incremental solution verify start.  */
    3094                 :             :   NULL,                            /* Incremental solution verify end.  */
    3095                 :             :   NULL,                            /* Dependent problem.  */
    3096                 :             :   sizeof (class df_word_lr_bb_info),/* Size of entry of block_info array.  */
    3097                 :             :   TV_DF_WORD_LR,                   /* Timing variable.  */
    3098                 :             :   false                            /* Reset blocks on dropping out of blocks_to_analyze.  */
    3099                 :             : };
    3100                 :             : 
    3101                 :             : 
    3102                 :             : /* Create a new DATAFLOW instance and add it to an existing instance
    3103                 :             :    of DF.  The returned structure is what is used to get at the
    3104                 :             :    solution.  */
    3105                 :             : 
    3106                 :             : void
    3107                 :      147211 : df_word_lr_add_problem (void)
    3108                 :             : {
    3109                 :      147211 :   df_add_problem (&problem_WORD_LR);
    3110                 :             :   /* These will be initialized when df_scan_blocks processes each
    3111                 :             :      block.  */
    3112                 :      147211 :   df_word_lr->out_of_date_transfer_functions = BITMAP_ALLOC (&df_bitmap_obstack);
    3113                 :      147211 : }
    3114                 :             : 
    3115                 :             : 
    3116                 :             : /* Simulate the effects of the defs of INSN on LIVE.  Return true if we changed
    3117                 :             :    any bits, which is used by the caller to determine whether a set is
    3118                 :             :    necessary.  We also return true if there are other reasons not to delete
    3119                 :             :    an insn.  */
    3120                 :             : 
    3121                 :             : bool
    3122                 :    20582116 : df_word_lr_simulate_defs (rtx_insn *insn, bitmap live)
    3123                 :             : {
    3124                 :    20582116 :   bool changed = false;
    3125                 :    20582116 :   df_ref def;
    3126                 :             : 
    3127                 :   165008287 :   FOR_EACH_INSN_DEF (def, insn)
    3128                 :   144426171 :     if (DF_REF_FLAGS (def) & DF_REF_CONDITIONAL)
    3129                 :             :       changed = true;
    3130                 :             :     else
    3131                 :   144426171 :       changed |= df_word_lr_mark_ref (def, false, live);
    3132                 :    20582116 :   return changed;
    3133                 :             : }
    3134                 :             : 
    3135                 :             : 
    3136                 :             : /* Simulate the effects of the uses of INSN on LIVE.  */
    3137                 :             : 
    3138                 :             : void
    3139                 :    20567725 : df_word_lr_simulate_uses (rtx_insn *insn, bitmap live)
    3140                 :             : {
    3141                 :    20567725 :   df_ref use;
    3142                 :             : 
    3143                 :    46731859 :   FOR_EACH_INSN_USE (use, insn)
    3144                 :    26164134 :     df_word_lr_mark_ref (use, true, live);
    3145                 :    20567725 : }
    3146                 :             : 
    3147                 :             : /*----------------------------------------------------------------------------
    3148                 :             :    This problem computes REG_DEAD and REG_UNUSED notes.
    3149                 :             :    ----------------------------------------------------------------------------*/
    3150                 :             : 
    3151                 :             : static void
    3152                 :    14934328 : df_note_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
    3153                 :             : {
    3154                 :    14934328 :   df_note->optional_p = true;
    3155                 :    14934328 : }
    3156                 :             : 
    3157                 :             : /* This is only used if REG_DEAD_DEBUGGING is in effect.  */
    3158                 :             : static void
    3159                 :           0 : df_print_note (const char *prefix, rtx_insn *insn, rtx note)
    3160                 :             : {
    3161                 :           0 :   if (dump_file)
    3162                 :             :     {
    3163                 :           0 :       fprintf (dump_file, "%s %d ", prefix, INSN_UID (insn));
    3164                 :           0 :       print_rtl (dump_file, note);
    3165                 :           0 :       fprintf (dump_file, "\n");
    3166                 :             :     }
    3167                 :           0 : }
    3168                 :             : 
    3169                 :             : 
    3170                 :             : /* After reg-stack, the x86 floating point stack regs are difficult to
    3171                 :             :    analyze because of all of the pushes, pops and rotations.  Thus, we
    3172                 :             :    just leave the notes alone. */
    3173                 :             : 
    3174                 :             : #ifdef STACK_REGS
    3175                 :             : static inline bool
    3176                 :  1203883632 : df_ignore_stack_reg (int regno)
    3177                 :             : {
    3178                 :  1203883632 :   return regstack_completed
    3179                 :   542582791 :     && IN_RANGE (regno, FIRST_STACK_REG, LAST_STACK_REG);
    3180                 :             : }
    3181                 :             : #else
    3182                 :             : static inline bool
    3183                 :             : df_ignore_stack_reg (int regno ATTRIBUTE_UNUSED)
    3184                 :             : {
    3185                 :             :   return false;
    3186                 :             : }
    3187                 :             : #endif
    3188                 :             : 
    3189                 :             : 
    3190                 :             : /* Remove all of the REG_DEAD or REG_UNUSED notes from INSN.  */
    3191                 :             : 
    3192                 :             : static void
    3193                 :  1571767756 : df_remove_dead_and_unused_notes (rtx_insn *insn)
    3194                 :             : {
    3195                 :  1571767756 :   rtx *pprev = &REG_NOTES (insn);
    3196                 :  1571767756 :   rtx link = *pprev;
    3197                 :             : 
    3198                 :  2450539763 :   while (link)
    3199                 :             :     {
    3200                 :   878772007 :       switch (REG_NOTE_KIND (link))
    3201                 :             :         {
    3202                 :   431568583 :         case REG_DEAD:
    3203                 :             :           /* After reg-stack, we need to ignore any unused notes
    3204                 :             :              for the stack registers.  */
    3205                 :   431568583 :           if (df_ignore_stack_reg (REGNO (XEXP (link, 0))))
    3206                 :             :             {
    3207                 :           0 :               pprev = &XEXP (link, 1);
    3208                 :           0 :               link = *pprev;
    3209                 :             :             }
    3210                 :             :           else
    3211                 :             :             {
    3212                 :   431568583 :               rtx next = XEXP (link, 1);
    3213                 :   431568583 :               if (REG_DEAD_DEBUGGING)
    3214                 :             :                 df_print_note ("deleting: ", insn, link);
    3215                 :   431568583 :               free_EXPR_LIST_node (link);
    3216                 :   431568583 :               *pprev = link = next;
    3217                 :             :             }
    3218                 :             :           break;
    3219                 :             : 
    3220                 :   111014208 :         case REG_UNUSED:
    3221                 :             :           /* After reg-stack, we need to ignore any unused notes
    3222                 :             :              for the stack registers.  */
    3223                 :   111014208 :           if (df_ignore_stack_reg (REGNO (XEXP (link, 0))))
    3224                 :             :             {
    3225                 :           0 :               pprev = &XEXP (link, 1);
    3226                 :           0 :               link = *pprev;
    3227                 :             :             }
    3228                 :             :           else
    3229                 :             :             {
    3230                 :   111014208 :               rtx next = XEXP (link, 1);
    3231                 :   111014208 :               if (REG_DEAD_DEBUGGING)
    3232                 :             :                 df_print_note ("deleting: ", insn, link);
    3233                 :   111014208 :               free_EXPR_LIST_node (link);
    3234                 :   111014208 :               *pprev = link = next;
    3235                 :             :             }
    3236                 :             :           break;
    3237                 :             : 
    3238                 :   336189216 :         default:
    3239                 :   336189216 :           pprev = &XEXP (link, 1);
    3240                 :   336189216 :           link = *pprev;
    3241                 :   336189216 :           break;
    3242                 :             :         }
    3243                 :             :     }
    3244                 :  1571767756 : }
    3245                 :             : 
    3246                 :             : /* Remove REG_EQUAL/REG_EQUIV notes referring to dead pseudos using LIVE
    3247                 :             :    as the bitmap of currently live registers.  */
    3248                 :             : 
    3249                 :             : static void
    3250                 :  1571767756 : df_remove_dead_eq_notes (rtx_insn *insn, bitmap live)
    3251                 :             : {
    3252                 :  1571767756 :   rtx *pprev = &REG_NOTES (insn);
    3253                 :  1571767756 :   rtx link = *pprev;
    3254                 :             : 
    3255                 :  2566851288 :   while (link)
    3256                 :             :     {
    3257                 :   995083532 :       switch (REG_NOTE_KIND (link))
    3258                 :             :         {
    3259                 :    68761086 :         case REG_EQUAL:
    3260                 :    68761086 :         case REG_EQUIV:
    3261                 :    68761086 :           {
    3262                 :             :             /* Remove the notes that refer to dead registers.  As we have at most
    3263                 :             :                one REG_EQUAL/EQUIV note, all of EQ_USES will refer to this note
    3264                 :             :                so we need to purge the complete EQ_USES vector when removing
    3265                 :             :                the note using df_notes_rescan.  */
    3266                 :    68761086 :             df_ref use;
    3267                 :    68761086 :             bool deleted = false;
    3268                 :             : 
    3269                 :   116053001 :             FOR_EACH_INSN_EQ_USE (use, insn)
    3270                 :    47645845 :               if (DF_REF_REGNO (use) >= FIRST_PSEUDO_REGISTER
    3271                 :     8942320 :                   && DF_REF_LOC (use)
    3272                 :     8942320 :                   && (DF_REF_FLAGS (use) & DF_REF_IN_NOTE)
    3273                 :     8942320 :                   && !bitmap_bit_p (live, DF_REF_REGNO (use))
    3274                 :    48000935 :                   && loc_mentioned_in_p (DF_REF_LOC (use), XEXP (link, 0)))
    3275                 :             :                 {
    3276                 :             :                   deleted = true;
    3277                 :             :                   break;
    3278                 :             :                 }
    3279                 :    68761086 :             if (deleted)
    3280                 :             :               {
    3281                 :      353930 :                 rtx next;
    3282                 :      353930 :                 if (REG_DEAD_DEBUGGING)
    3283                 :             :                   df_print_note ("deleting: ", insn, link);
    3284                 :      353930 :                 next = XEXP (link, 1);
    3285                 :      353930 :                 free_EXPR_LIST_node (link);
    3286                 :      353930 :                 *pprev = link = next;
    3287                 :      353930 :                 df_notes_rescan (insn);
    3288                 :             :               }
    3289                 :             :             else
    3290                 :             :               {
    3291                 :    68407156 :                 pprev = &XEXP (link, 1);
    3292                 :    68407156 :                 link = *pprev;
    3293                 :             :               }
    3294                 :             :             break;
    3295                 :             :           }
    3296                 :             : 
    3297                 :   926322446 :         default:
    3298                 :   926322446 :           pprev = &XEXP (link, 1);
    3299                 :   926322446 :           link = *pprev;
    3300                 :   926322446 :           break;
    3301                 :             :         }
    3302                 :             :     }
    3303                 :  1571767756 : }
    3304                 :             : 
    3305                 :             : /* Set a NOTE_TYPE note for REG in INSN.  */
    3306                 :             : 
    3307                 :             : static inline void
    3308                 :   658894316 : df_set_note (enum reg_note note_type, rtx_insn *insn, rtx reg)
    3309                 :             : {
    3310                 :   658894316 :   gcc_checking_assert (!DEBUG_INSN_P (insn));
    3311                 :   658894316 :   add_reg_note (insn, note_type, reg);
    3312                 :   658894316 : }
    3313                 :             : 
    3314                 :             : /* A subroutine of df_set_unused_notes_for_mw, with a selection of its
    3315                 :             :    arguments.  Return true if the register value described by MWS's
    3316                 :             :    mw_reg is known to be completely unused, and if mw_reg can therefore
    3317                 :             :    be used in a REG_UNUSED note.  */
    3318                 :             : 
    3319                 :             : static bool
    3320                 :     2534799 : df_whole_mw_reg_unused_p (struct df_mw_hardreg *mws,
    3321                 :             :                           bitmap live, bitmap artificial_uses)
    3322                 :             : {
    3323                 :     2534799 :   unsigned int r;
    3324                 :             : 
    3325                 :             :   /* If MWS describes a partial reference, create REG_UNUSED notes for
    3326                 :             :      individual hard registers.  */
    3327                 :     2534799 :   if (mws->flags & DF_REF_PARTIAL)
    3328                 :             :     return false;
    3329                 :             : 
    3330                 :             :   /* Likewise if some part of the register is used.  */
    3331                 :     2910085 :   for (r = mws->start_regno; r <= mws->end_regno; r++)
    3332                 :     2735695 :     if (bitmap_bit_p (live, r)
    3333                 :     2735695 :         || bitmap_bit_p (artificial_uses, r))
    3334                 :     2360409 :       return false;
    3335                 :             : 
    3336                 :      174390 :   gcc_assert (REG_P (mws->mw_reg));
    3337                 :             :   return true;
    3338                 :             : }
    3339                 :             : 
    3340                 :             : 
    3341                 :             : /* Set the REG_UNUSED notes for the multiword hardreg defs in INSN
    3342                 :             :    based on the bits in LIVE.  Do not generate notes for registers in
    3343                 :             :    artificial uses.  DO_NOT_GEN is updated so that REG_DEAD notes are
    3344                 :             :    not generated if the reg is both read and written by the
    3345                 :             :    instruction.
    3346                 :             : */
    3347                 :             : 
    3348                 :             : static void
    3349                 :     2534799 : df_set_unused_notes_for_mw (rtx_insn *insn, struct df_mw_hardreg *mws,
    3350                 :             :                             bitmap live, bitmap do_not_gen,
    3351                 :             :                             bitmap artificial_uses,
    3352                 :             :                             struct dead_debug_local *debug)
    3353                 :             : {
    3354                 :     2534799 :   unsigned int r;
    3355                 :             : 
    3356                 :     2534799 :   if (REG_DEAD_DEBUGGING && dump_file)
    3357                 :             :     fprintf (dump_file, "mw_set_unused looking at mws[%d..%d]\n",
    3358                 :             :              mws->start_regno, mws->end_regno);
    3359                 :             : 
    3360                 :     2534799 :   if (df_whole_mw_reg_unused_p (mws, live, artificial_uses))
    3361                 :             :     {
    3362                 :      174390 :       unsigned int regno = mws->start_regno;
    3363                 :      174390 :       df_set_note (REG_UNUSED, insn, mws->mw_reg);
    3364                 :      174390 :       dead_debug_insert_temp (debug, regno, insn, DEBUG_TEMP_AFTER_WITH_REG);
    3365                 :             : 
    3366                 :      174390 :       if (REG_DEAD_DEBUGGING)
    3367                 :             :         df_print_note ("adding 1: ", insn, REG_NOTES (insn));
    3368                 :             : 
    3369                 :      174390 :       bitmap_set_bit (do_not_gen, regno);
    3370                 :             :       /* Only do this if the value is totally dead.  */
    3371                 :             :     }
    3372                 :             :   else
    3373                 :     7081227 :     for (r = mws->start_regno; r <= mws->end_regno; r++)
    3374                 :             :       {
    3375                 :     4720818 :         if (!bitmap_bit_p (live, r)
    3376                 :     4720818 :             && !bitmap_bit_p (artificial_uses, r))
    3377                 :             :           {
    3378                 :      114377 :             df_set_note (REG_UNUSED, insn, regno_reg_rtx[r]);
    3379                 :      114377 :             dead_debug_insert_temp (debug, r, insn, DEBUG_TEMP_AFTER_WITH_REG);
    3380                 :      114377 :             if (REG_DEAD_DEBUGGING)
    3381                 :             :               df_print_note ("adding 2: ", insn, REG_NOTES (insn));
    3382                 :             :           }
    3383                 :     4720818 :         bitmap_set_bit (do_not_gen, r);
    3384                 :             :       }
    3385                 :     2534799 : }
    3386                 :             : 
    3387                 :             : 
    3388                 :             : /* A subroutine of df_set_dead_notes_for_mw, with a selection of its
    3389                 :             :    arguments.  Return true if the register value described by MWS's
    3390                 :             :    mw_reg is known to be completely dead, and if mw_reg can therefore
    3391                 :             :    be used in a REG_DEAD note.  */
    3392                 :             : 
    3393                 :             : static bool
    3394                 :     1916604 : df_whole_mw_reg_dead_p (struct df_mw_hardreg *mws,
    3395                 :             :                         bitmap live, bitmap artificial_uses,
    3396                 :             :                         bitmap do_not_gen)
    3397                 :             : {
    3398                 :     1916604 :   unsigned int r;
    3399                 :             : 
    3400                 :             :   /* If MWS describes a partial reference, create REG_DEAD notes for
    3401                 :             :      individual hard registers.  */
    3402                 :     1916604 :   if (mws->flags & DF_REF_PARTIAL)
    3403                 :             :     return false;
    3404                 :             : 
    3405                 :             :   /* Likewise if some part of the register is not dead.  */
    3406                 :     3996495 :   for (r = mws->start_regno; r <= mws->end_regno; r++)
    3407                 :     2957378 :     if (bitmap_bit_p (live, r)
    3408                 :     2289980 :         || bitmap_bit_p (artificial_uses, r)
    3409                 :     5247358 :         || bitmap_bit_p (do_not_gen, r))
    3410                 :      876332 :       return false;
    3411                 :             : 
    3412                 :     1039117 :   gcc_assert (REG_P (mws->mw_reg));
    3413                 :             :   return true;
    3414                 :             : }
    3415                 :             : 
    3416                 :             : /* Set the REG_DEAD notes for the multiword hardreg use in INSN based
    3417                 :             :    on the bits in LIVE.  DO_NOT_GEN is used to keep REG_DEAD notes
    3418                 :             :    from being set if the instruction both reads and writes the
    3419                 :             :    register.  */
    3420                 :             : 
    3421                 :             : static void
    3422                 :     1916604 : df_set_dead_notes_for_mw (rtx_insn *insn, struct df_mw_hardreg *mws,
    3423                 :             :                           bitmap live, bitmap do_not_gen,
    3424                 :             :                           bitmap artificial_uses, bool *added_notes_p)
    3425                 :             : {
    3426                 :     1916604 :   unsigned int r;
    3427                 :     1916604 :   bool is_debug = *added_notes_p;
    3428                 :             : 
    3429                 :     1916604 :   *added_notes_p = false;
    3430                 :             : 
    3431                 :     1916604 :   if (REG_DEAD_DEBUGGING && dump_file)
    3432                 :             :     {
    3433                 :             :       fprintf (dump_file, "mw_set_dead looking at mws[%d..%d]\n  do_not_gen =",
    3434                 :             :                mws->start_regno, mws->end_regno);
    3435                 :             :       df_print_regset (dump_file, do_not_gen);
    3436                 :             :       fprintf (dump_file, "  live =");
    3437                 :             :       df_print_regset (dump_file, live);
    3438                 :             :       fprintf (dump_file, "  artificial uses =");
    3439                 :             :       df_print_regset (dump_file, artificial_uses);
    3440                 :             :     }
    3441                 :             : 
    3442                 :     1916604 :   if (df_whole_mw_reg_dead_p (mws, live, artificial_uses, do_not_gen))
    3443                 :             :     {
    3444                 :     1039117 :       if (is_debug)
    3445                 :             :         {
    3446                 :         562 :           *added_notes_p = true;
    3447                 :         562 :           return;
    3448                 :             :         }
    3449                 :             :       /* Add a dead note for the entire multi word register.  */
    3450                 :     1038555 :       df_set_note (REG_DEAD, insn, mws->mw_reg);
    3451                 :     1038555 :       if (REG_DEAD_DEBUGGING)
    3452                 :             :         df_print_note ("adding 1: ", insn, REG_NOTES (insn));
    3453                 :             :     }
    3454                 :             :   else
    3455                 :             :     {
    3456                 :     2627692 :       for (r = mws->start_regno; r <= mws->end_regno; r++)
    3457                 :     1753963 :         if (!bitmap_bit_p (live, r)
    3458                 :      421550 :             && !bitmap_bit_p (artificial_uses, r)
    3459                 :     2175513 :             && !bitmap_bit_p (do_not_gen, r))
    3460                 :             :           {
    3461                 :      147311 :             if (is_debug)
    3462                 :             :               {
    3463                 :        3758 :                 *added_notes_p = true;
    3464                 :        3758 :                 return;
    3465                 :             :               }
    3466                 :      143553 :             df_set_note (REG_DEAD, insn, regno_reg_rtx[r]);
    3467                 :      143553 :             if (REG_DEAD_DEBUGGING)
    3468                 :             :               df_print_note ("adding 2: ", insn, REG_NOTES (insn));
    3469                 :             :           }
    3470                 :             :     }
    3471                 :             :   return;
    3472                 :             : }
    3473                 :             : 
    3474                 :             : 
    3475                 :             : /* Create a REG_UNUSED note if necessary for DEF in INSN updating
    3476                 :             :    LIVE.  Do not generate notes for registers in ARTIFICIAL_USES.  */
    3477                 :             : 
    3478                 :             : static void
    3479                 :   816324929 : df_create_unused_note (rtx_insn *insn, df_ref def,
    3480                 :             :                        bitmap live, bitmap artificial_uses,
    3481                 :             :                        struct dead_debug_local *debug)
    3482                 :             : {
    3483                 :   816324929 :   unsigned int dregno = DF_REF_REGNO (def);
    3484                 :             : 
    3485                 :   816324929 :   if (REG_DEAD_DEBUGGING && dump_file)
    3486                 :             :     {
    3487                 :             :       fprintf (dump_file, "  regular looking at def ");
    3488                 :             :       df_ref_debug (def, dump_file);
    3489                 :             :     }
    3490                 :             : 
    3491                 :   816324929 :   if (!((DF_REF_FLAGS (def) & DF_REF_MW_HARDREG)
    3492                 :   811254827 :         || bitmap_bit_p (live, dregno)
    3493                 :   135450017 :         || bitmap_bit_p (artificial_uses, dregno)
    3494                 :   135434794 :         || df_ignore_stack_reg (dregno)))
    3495                 :             :     {
    3496                 :   135434794 :       rtx reg = (DF_REF_LOC (def))
    3497                 :   135434794 :                 ? *DF_REF_REAL_LOC (def): DF_REF_REG (def);
    3498                 :   135434794 :       df_set_note (REG_UNUSED, insn, reg);
    3499                 :   135434794 :       dead_debug_insert_temp (debug, dregno, insn, DEBUG_TEMP_AFTER_WITH_REG);
    3500                 :   135434794 :       if (REG_DEAD_DEBUGGING)
    3501                 :             :         df_print_note ("adding 3: ", insn, REG_NOTES (insn));
    3502                 :             :     }
    3503                 :             : 
    3504                 :   816324929 :   return;
    3505                 :             : }
    3506                 :             : 
    3507                 :             : 
    3508                 :             : /* Recompute the REG_DEAD and REG_UNUSED notes and compute register
    3509                 :             :    info: lifetime, bb, and number of defs and uses for basic block
    3510                 :             :    BB.  The three bitvectors are scratch regs used here.  */
    3511                 :             : 
    3512                 :             : static void
    3513                 :   192936586 : df_note_bb_compute (unsigned int bb_index,
    3514                 :             :                     bitmap live, bitmap do_not_gen, bitmap artificial_uses)
    3515                 :             : {
    3516                 :   192936586 :   basic_block bb = BASIC_BLOCK_FOR_FN (cfun, bb_index);
    3517                 :   192936586 :   rtx_insn *insn;
    3518                 :   192936586 :   df_ref def, use;
    3519                 :   192936586 :   struct dead_debug_local debug;
    3520                 :             : 
    3521                 :   192936586 :   dead_debug_local_init (&debug, NULL, NULL);
    3522                 :             : 
    3523                 :   192936586 :   bitmap_copy (live, df_get_live_out (bb));
    3524                 :   192936586 :   bitmap_clear (artificial_uses);
    3525                 :             : 
    3526                 :   192936586 :   if (REG_DEAD_DEBUGGING && dump_file)
    3527                 :             :     {
    3528                 :             :       fprintf (dump_file, "live at bottom ");
    3529                 :             :       df_print_regset (dump_file, live);
    3530                 :             :     }
    3531                 :             : 
    3532                 :             :   /* Process the artificial defs and uses at the bottom of the block
    3533                 :             :      to begin processing.  */
    3534                 :   643369448 :   FOR_EACH_ARTIFICIAL_DEF (def, bb_index)
    3535                 :             :     {
    3536                 :   257496276 :       if (REG_DEAD_DEBUGGING && dump_file)
    3537                 :             :         fprintf (dump_file, "artificial def %d\n", DF_REF_REGNO (def));
    3538                 :             : 
    3539                 :   257496276 :       if ((DF_REF_FLAGS (def) & DF_REF_AT_TOP) == 0)
    3540                 :   251407289 :         bitmap_clear_bit (live, DF_REF_REGNO (def));
    3541                 :             :     }
    3542                 :             : 
    3543                 :   891707898 :   FOR_EACH_ARTIFICIAL_USE (use, bb_index)
    3544                 :   505834726 :     if ((DF_REF_FLAGS (use) & DF_REF_AT_TOP) == 0)
    3545                 :             :       {
    3546                 :   505834726 :         unsigned int regno = DF_REF_REGNO (use);
    3547                 :   505834726 :         bitmap_set_bit (live, regno);
    3548                 :             : 
    3549                 :             :         /* Notes are not generated for any of the artificial registers
    3550                 :             :            at the bottom of the block.  */
    3551                 :   505834726 :         bitmap_set_bit (artificial_uses, regno);
    3552                 :             :       }
    3553                 :             : 
    3554                 :   192936586 :   if (REG_DEAD_DEBUGGING && dump_file)
    3555                 :             :     {
    3556                 :             :       fprintf (dump_file, "live before artificials out ");
    3557                 :             :       df_print_regset (dump_file, live);
    3558                 :             :     }
    3559                 :             : 
    3560                 :  2080951574 :   FOR_BB_INSNS_REVERSE (bb, insn)
    3561                 :             :     {
    3562                 :  2204262220 :       if (!INSN_P (insn))
    3563                 :   316247232 :         continue;
    3564                 :             : 
    3565                 :  1571767756 :       df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
    3566                 :  1571767756 :       df_mw_hardreg *mw;
    3567                 :  1571767756 :       int debug_insn;
    3568                 :             : 
    3569                 :  1571767756 :       debug_insn = DEBUG_INSN_P (insn);
    3570                 :             : 
    3571                 :  1571767756 :       bitmap_clear (do_not_gen);
    3572                 :  1571767756 :       df_remove_dead_and_unused_notes (insn);
    3573                 :             : 
    3574                 :             :       /* Process the defs.  */
    3575                 :  1571767756 :       if (CALL_P (insn))
    3576                 :             :         {
    3577                 :    71311307 :           if (REG_DEAD_DEBUGGING && dump_file)
    3578                 :             :             {
    3579                 :             :               fprintf (dump_file, "processing call %d\n  live =",
    3580                 :             :                        INSN_UID (insn));
    3581                 :             :               df_print_regset (dump_file, live);
    3582                 :             :             }
    3583                 :             : 
    3584                 :             :           /* We only care about real sets for calls.  Clobbers cannot
    3585                 :             :              be depended on to really die.  */
    3586                 :    73863571 :           FOR_EACH_INSN_INFO_MW (mw, insn_info)
    3587                 :     2552264 :             if ((DF_MWS_REG_DEF_P (mw))
    3588                 :     4323887 :                 && !df_ignore_stack_reg (mw->start_regno))
    3589                 :     1771623 :               df_set_unused_notes_for_mw (insn, mw, live, do_not_gen,
    3590                 :             :                                           artificial_uses, &debug);
    3591                 :             : 
    3592                 :             :           /* All of the defs except the return value are some sort of
    3593                 :             :              clobber.  This code is for the return.  */
    3594                 :  5906606651 :           FOR_EACH_INSN_INFO_DEF (def, insn_info)
    3595                 :             :             {
    3596                 :  5835295344 :               unsigned int dregno = DF_REF_REGNO (def);
    3597                 :  5835295344 :               if (!DF_REF_FLAGS_IS_SET (def, DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER))
    3598                 :             :                 {
    3599                 :    33459665 :                   df_create_unused_note (insn,
    3600                 :             :                                          def, live, artificial_uses, &debug);
    3601                 :    33459665 :                   bitmap_set_bit (do_not_gen, dregno);
    3602                 :             :                 }
    3603                 :             : 
    3604                 :  5835295344 :               if (!DF_REF_FLAGS_IS_SET (def, DF_REF_PARTIAL | DF_REF_CONDITIONAL))
    3605                 :  5835295344 :                 bitmap_clear_bit (live, dregno);
    3606                 :             :             }
    3607                 :             :         }
    3608                 :             :       else
    3609                 :             :         {
    3610                 :             :           /* Regular insn.  */
    3611                 :  1502355588 :           FOR_EACH_INSN_INFO_MW (mw, insn_info)
    3612                 :     1899139 :             if (DF_MWS_REG_DEF_P (mw))
    3613                 :      763176 :               df_set_unused_notes_for_mw (insn, mw, live, do_not_gen,
    3614                 :             :                                           artificial_uses, &debug);
    3615                 :             : 
    3616                 :  2283321713 :           FOR_EACH_INSN_INFO_DEF (def, insn_info)
    3617                 :             :             {
    3618                 :   782865264 :               unsigned int dregno = DF_REF_REGNO (def);
    3619                 :   782865264 :               df_create_unused_note (insn,
    3620                 :             :                                      def, live, artificial_uses, &debug);
    3621                 :             : 
    3622                 :   782865264 :               if (!DF_REF_FLAGS_IS_SET (def, DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER))
    3623                 :   660382822 :                 bitmap_set_bit (do_not_gen, dregno);
    3624                 :             : 
    3625                 :   782865264 :               if (!DF_REF_FLAGS_IS_SET (def, DF_REF_PARTIAL | DF_REF_CONDITIONAL))
    3626                 :   780426255 :                 bitmap_clear_bit (live, dregno);
    3627                 :             :             }
    3628                 :             :         }
    3629                 :             : 
    3630                 :             :       /* Process the uses.  */
    3631                 :  1576219159 :       FOR_EACH_INSN_INFO_MW (mw, insn_info)
    3632                 :     4451403 :         if (DF_MWS_REG_USE_P (mw)
    3633                 :     6368007 :             && !df_ignore_stack_reg (mw->start_regno))
    3634                 :             :           {
    3635                 :     1916604 :             bool really_add_notes = debug_insn != 0;
    3636                 :             : 
    3637                 :     1916604 :             df_set_dead_notes_for_mw (insn, mw, live, do_not_gen,
    3638                 :             :                                       artificial_uses,
    3639                 :             :                                       &really_add_notes);
    3640                 :             : 
    3641                 :     1916604 :             if (really_add_notes)
    3642                 :        4320 :               debug_insn = -1;
    3643                 :             :           }
    3644                 :             : 
    3645                 :  2889000910 :       FOR_EACH_INSN_INFO_USE (use, insn_info)
    3646                 :             :         {
    3647                 :  1317237474 :           unsigned int uregno = DF_REF_REGNO (use);
    3648                 :             : 
    3649                 :  1317237474 :           if (REG_DEAD_DEBUGGING && dump_file && !debug_insn)
    3650                 :             :             {
    3651                 :             :               fprintf (dump_file, "  regular looking at use ");
    3652                 :             :               df_ref_debug (use, dump_file);
    3653                 :             :             }
    3654                 :             : 
    3655                 :  1317237474 :           if (!bitmap_bit_p (live, uregno))
    3656                 :             :             {
    3657                 :   661954210 :               if (debug_insn)
    3658                 :             :                 {
    3659                 :      193521 :                   if (debug_insn > 0)
    3660                 :             :                     {
    3661                 :             :                       /* We won't add REG_UNUSED or REG_DEAD notes for
    3662                 :             :                          these, so we don't have to mess with them in
    3663                 :             :                          debug insns either.  */
    3664                 :      189201 :                       if (!bitmap_bit_p (artificial_uses, uregno)
    3665                 :      189201 :                           && !df_ignore_stack_reg (uregno))
    3666                 :      189173 :                         dead_debug_add (&debug, use, uregno);
    3667                 :      189201 :                       continue;
    3668                 :             :                     }
    3669                 :             :                   break;
    3670                 :             :                 }
    3671                 :             :               else
    3672                 :   661760689 :                 dead_debug_insert_temp (&debug, uregno, insn,
    3673                 :             :                                         DEBUG_TEMP_BEFORE_WITH_REG);
    3674                 :             : 
    3675                 :   661760689 :               if ( (!(DF_REF_FLAGS (use)
    3676                 :             :                       & (DF_REF_MW_HARDREG | DF_REF_READ_WRITE)))
    3677                 :   659262318 :                    && (!bitmap_bit_p (do_not_gen, uregno))
    3678                 :   522473412 :                    && (!bitmap_bit_p (artificial_uses, uregno))
    3679                 :  1183749336 :                    && (!df_ignore_stack_reg (uregno)))
    3680                 :             :                 {
    3681                 :   521988647 :                   rtx reg = (DF_REF_LOC (use))
    3682                 :   521988647 :                             ? *DF_REF_REAL_LOC (use) : DF_REF_REG (use);
    3683                 :   521988647 :                   df_set_note (REG_DEAD, insn, reg);
    3684                 :             : 
    3685                 :   521988647 :                   if (REG_DEAD_DEBUGGING)
    3686                 :             :                     df_print_note ("adding 4: ", insn, REG_NOTES (insn));
    3687                 :             :                 }
    3688                 :             :               /* This register is now live.  */
    3689                 :   661760689 :               bitmap_set_bit (live, uregno);
    3690                 :             :             }
    3691                 :             :         }
    3692                 :             : 
    3693                 :  1571767756 :       df_remove_dead_eq_notes (insn, live);
    3694                 :             : 
    3695                 :  1571767756 :       if (debug_insn == -1)
    3696                 :             :         {
    3697                 :             :           /* ??? We could probably do better here, replacing dead
    3698                 :             :              registers with their definitions.  */
    3699                 :        4320 :           INSN_VAR_LOCATION_LOC (insn) = gen_rtx_UNKNOWN_VAR_LOC ();
    3700                 :        4320 :           df_insn_rescan_debug_internal (insn);
    3701                 :             :         }
    3702                 :             :     }
    3703                 :             : 
    3704                 :   192936586 :   dead_debug_local_finish (&debug, NULL);
    3705                 :   192936586 : }
    3706                 :             : 
    3707                 :             : 
    3708                 :             : /* Compute register info: lifetime, bb, and number of defs and uses.  */
    3709                 :             : static void
    3710                 :    14934328 : df_note_compute (bitmap all_blocks)
    3711                 :             : {
    3712                 :    14934328 :   unsigned int bb_index;
    3713                 :    14934328 :   bitmap_iterator bi;
    3714                 :    14934328 :   bitmap_head live, do_not_gen, artificial_uses;
    3715                 :             : 
    3716                 :    14934328 :   bitmap_initialize (&live, &df_bitmap_obstack);
    3717                 :    14934328 :   bitmap_initialize (&do_not_gen, &df_bitmap_obstack);
    3718                 :    14934328 :   bitmap_initialize (&artificial_uses, &df_bitmap_obstack);
    3719                 :             : 
    3720                 :   207870914 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
    3721                 :             :   {
    3722                 :             :     /* ??? Unlike fast DCE, we don't use global_debug for uses of dead
    3723                 :             :        pseudos in debug insns because we don't always (re)visit blocks
    3724                 :             :        with death points after visiting dead uses.  Even changing this
    3725                 :             :        loop to postorder would still leave room for visiting a death
    3726                 :             :        point before visiting a subsequent debug use.  */
    3727                 :   192936586 :     df_note_bb_compute (bb_index, &live, &do_not_gen, &artificial_uses);
    3728                 :             :   }
    3729                 :             : 
    3730                 :    14934328 :   bitmap_clear (&live);
    3731                 :    14934328 :   bitmap_clear (&do_not_gen);
    3732                 :    14934328 :   bitmap_clear (&artificial_uses);
    3733                 :    14934328 : }
    3734                 :             : 
    3735                 :             : 
    3736                 :             : /* Free all storage associated with the problem.  */
    3737                 :             : 
    3738                 :             : static void
    3739                 :    10652910 : df_note_free (void)
    3740                 :             : {
    3741                 :    10652910 :   free (df_note);
    3742                 :    10652910 : }
    3743                 :             : 
    3744                 :             : 
    3745                 :             : /* All of the information associated every instance of the problem.  */
    3746                 :             : 
    3747                 :             : static const struct df_problem problem_NOTE =
    3748                 :             : {
    3749                 :             :   DF_NOTE,                    /* Problem id.  */
    3750                 :             :   DF_NONE,                    /* Direction.  */
    3751                 :             :   df_note_alloc,              /* Allocate the problem specific data.  */
    3752                 :             :   NULL,                       /* Reset global information.  */
    3753                 :             :   NULL,                       /* Free basic block info.  */
    3754                 :             :   df_note_compute,            /* Local compute function.  */
    3755                 :             :   NULL,                       /* Init the solution specific data.  */
    3756                 :             :   NULL,                       /* Iterative solver.  */
    3757                 :             :   NULL,                       /* Confluence operator 0.  */
    3758                 :             :   NULL,                       /* Confluence operator n.  */
    3759                 :             :   NULL,                       /* Transfer function.  */
    3760                 :             :   NULL,                       /* Finalize function.  */
    3761                 :             :   df_note_free,               /* Free all of the problem information.  */
    3762                 :             :   df_note_free,               /* Remove this problem from the stack of dataflow problems.  */
    3763                 :             :   NULL,                       /* Debugging.  */
    3764                 :             :   NULL,                       /* Debugging start block.  */
    3765                 :             :   NULL,                       /* Debugging end block.  */
    3766                 :             :   NULL,                       /* Debugging start insn.  */
    3767                 :             :   NULL,                       /* Debugging end insn.  */
    3768                 :             :   NULL,                       /* Incremental solution verify start.  */
    3769                 :             :   NULL,                       /* Incremental solution verify end.  */
    3770                 :             :   &problem_LR,                /* Dependent problem.  */
    3771                 :             :   sizeof (struct df_scan_bb_info),/* Size of entry of block_info array.  */
    3772                 :             :   TV_DF_NOTE,                 /* Timing variable.  */
    3773                 :             :   false                       /* Reset blocks on dropping out of blocks_to_analyze.  */
    3774                 :             : };
    3775                 :             : 
    3776                 :             : 
    3777                 :             : /* Create a new DATAFLOW instance and add it to an existing instance
    3778                 :             :    of DF.  The returned structure is what is used to get at the
    3779                 :             :    solution.  */
    3780                 :             : 
    3781                 :             : void
    3782                 :    11033323 : df_note_add_problem (void)
    3783                 :             : {
    3784                 :    11033323 :   df_add_problem (&problem_NOTE);
    3785                 :    11033323 : }
    3786                 :             : 
    3787                 :             : 
    3788                 :             : 
    3789                 :             : 
    3790                 :             : /*----------------------------------------------------------------------------
    3791                 :             :    Functions for simulating the effects of single insns.
    3792                 :             : 
    3793                 :             :    You can either simulate in the forwards direction, starting from
    3794                 :             :    the top of a block or the backwards direction from the end of the
    3795                 :             :    block.  If you go backwards, defs are examined first to clear bits,
    3796                 :             :    then uses are examined to set bits.  If you go forwards, defs are
    3797                 :             :    examined first to set bits, then REG_DEAD and REG_UNUSED notes
    3798                 :             :    are examined to clear bits.  In either case, the result of examining
    3799                 :             :    a def can be undone (respectively by a use or a REG_UNUSED note).
    3800                 :             : 
    3801                 :             :    If you start at the top of the block, use one of DF_LIVE_IN or
    3802                 :             :    DF_LR_IN.  If you start at the bottom of the block use one of
    3803                 :             :    DF_LIVE_OUT or DF_LR_OUT.  BE SURE TO PASS A COPY OF THESE SETS,
    3804                 :             :    THEY WILL BE DESTROYED.
    3805                 :             : ----------------------------------------------------------------------------*/
    3806                 :             : 
    3807                 :             : 
    3808                 :             : /* Find the set of DEFs for INSN.  */
    3809                 :             : 
    3810                 :             : void
    3811                 :     1837235 : df_simulate_find_defs (rtx_insn *insn, bitmap defs)
    3812                 :             : {
    3813                 :     1837235 :   df_ref def;
    3814                 :             : 
    3815                 :     3260316 :   FOR_EACH_INSN_DEF (def, insn)
    3816                 :     1423081 :     bitmap_set_bit (defs, DF_REF_REGNO (def));
    3817                 :     1837235 : }
    3818                 :             : 
    3819                 :             : /* Find the set of uses for INSN.  This includes partial defs.  */
    3820                 :             : 
    3821                 :             : static void
    3822                 :      469777 : df_simulate_find_uses (rtx_insn *insn, bitmap uses)
    3823                 :             : {
    3824                 :      469777 :   df_ref def, use;
    3825                 :      469777 :   struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
    3826                 :             : 
    3827                 :      993055 :   FOR_EACH_INSN_INFO_DEF (def, insn_info)
    3828                 :      523278 :     if (DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL))
    3829                 :         292 :       bitmap_set_bit (uses, DF_REF_REGNO (def));
    3830                 :      779605 :   FOR_EACH_INSN_INFO_USE (use, insn_info)
    3831                 :      309828 :     bitmap_set_bit (uses, DF_REF_REGNO (use));
    3832                 :      469777 : }
    3833                 :             : 
    3834                 :             : /* Find the set of real DEFs, which are not clobbers, for INSN.  */
    3835                 :             : 
    3836                 :             : void
    3837                 :   343359765 : df_simulate_find_noclobber_defs (rtx_insn *insn, bitmap defs)
    3838                 :             : {
    3839                 :   343359765 :   df_ref def;
    3840                 :             : 
    3841                 :  1991348785 :   FOR_EACH_INSN_DEF (def, insn)
    3842                 :  1647989020 :     if (!(DF_REF_FLAGS (def) & (DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER)))
    3843                 :   164316651 :       bitmap_set_bit (defs, DF_REF_REGNO (def));
    3844                 :   343359765 : }
    3845                 :             : 
    3846                 :             : 
    3847                 :             : /* Simulate the effects of the defs of INSN on LIVE.  */
    3848                 :             : 
    3849                 :             : void
    3850                 :   663456057 : df_simulate_defs (rtx_insn *insn, bitmap live)
    3851                 :             : {
    3852                 :   663456057 :   df_ref def;
    3853                 :             : 
    3854                 :  5328194748 :   FOR_EACH_INSN_DEF (def, insn)
    3855                 :             :     {
    3856                 :  4664738691 :       unsigned int dregno = DF_REF_REGNO (def);
    3857                 :             : 
    3858                 :             :       /* If the def is to only part of the reg, it does
    3859                 :             :          not kill the other defs that reach here.  */
    3860                 :  4664738691 :       if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
    3861                 :  4662523135 :         bitmap_clear_bit (live, dregno);
    3862                 :             :     }
    3863                 :   663456057 : }
    3864                 :             : 
    3865                 :             : 
    3866                 :             : /* Simulate the effects of the uses of INSN on LIVE.  */
    3867                 :             : 
    3868                 :             : void
    3869                 :   660516565 : df_simulate_uses (rtx_insn *insn, bitmap live)
    3870                 :             : {
    3871                 :   660516565 :   df_ref use;
    3872                 :             : 
    3873                 :   660516565 :   if (DEBUG_INSN_P (insn))
    3874                 :             :     return;
    3875                 :             : 
    3876                 :  1489395110 :   FOR_EACH_INSN_USE (use, insn)
    3877                 :             :     /* Add use to set of uses in this BB.  */
    3878                 :   828878545 :     bitmap_set_bit (live, DF_REF_REGNO (use));
    3879                 :             : }
    3880                 :             : 
    3881                 :             : 
    3882                 :             : /* Add back the always live regs in BB to LIVE.  */
    3883                 :             : 
    3884                 :             : static inline void
    3885                 :   346769980 : df_simulate_fixup_sets (basic_block bb, bitmap live)
    3886                 :             : {
    3887                 :             :   /* These regs are considered always live so if they end up dying
    3888                 :             :      because of some def, we need to bring the back again.  */
    3889                 :   346769980 :   if (bb_has_eh_pred (bb))
    3890                 :     1523577 :     bitmap_ior_into (live, &df->eh_block_artificial_uses);
    3891                 :             :   else
    3892                 :   345246403 :     bitmap_ior_into (live, &df->regular_block_artificial_uses);
    3893                 :   346769980 : }
    3894                 :             : 
    3895                 :             : 
    3896                 :             : /*----------------------------------------------------------------------------
    3897                 :             :    The following three functions are used only for BACKWARDS scanning:
    3898                 :             :    i.e. they process the defs before the uses.
    3899                 :             : 
    3900                 :             :    df_simulate_initialize_backwards should be called first with a
    3901                 :             :    bitvector copyied from the DF_LIVE_OUT or DF_LR_OUT.  Then
    3902                 :             :    df_simulate_one_insn_backwards should be called for each insn in
    3903                 :             :    the block, starting with the last one.  Finally,
    3904                 :             :    df_simulate_finalize_backwards can be called to get a new value
    3905                 :             :    of the sets at the top of the block (this is rarely used).
    3906                 :             :    ----------------------------------------------------------------------------*/
    3907                 :             : 
    3908                 :             : /* Apply the artificial uses and defs at the end of BB in a backwards
    3909                 :             :    direction.  */
    3910                 :             : 
    3911                 :             : void
    3912                 :   122799574 : df_simulate_initialize_backwards (basic_block bb, bitmap live)
    3913                 :             : {
    3914                 :   122799574 :   df_ref def, use;
    3915                 :   122799574 :   int bb_index = bb->index;
    3916                 :             : 
    3917                 :   250839281 :   FOR_EACH_ARTIFICIAL_DEF (def, bb_index)
    3918                 :     5240133 :     if ((DF_REF_FLAGS (def) & DF_REF_AT_TOP) == 0)
    3919                 :           0 :       bitmap_clear_bit (live, DF_REF_REGNO (def));
    3920                 :             : 
    3921                 :   618357245 :   FOR_EACH_ARTIFICIAL_USE (use, bb_index)
    3922                 :   372758097 :     if ((DF_REF_FLAGS (use) & DF_REF_AT_TOP) == 0)
    3923                 :   372758097 :       bitmap_set_bit (live, DF_REF_REGNO (use));
    3924                 :   122799574 : }
    3925                 :             : 
    3926                 :             : 
    3927                 :             : /* Simulate the backwards effects of INSN on the bitmap LIVE.  */
    3928                 :             : 
    3929                 :             : void
    3930                 :     3873938 : df_simulate_one_insn_backwards (basic_block bb, rtx_insn *insn, bitmap live)
    3931                 :             : {
    3932                 :     3873938 :   if (!NONDEBUG_INSN_P (insn))
    3933                 :             :     return;
    3934                 :             : 
    3935                 :     3410215 :   df_simulate_defs (insn, live);
    3936                 :     3410215 :   df_simulate_uses (insn, live);
    3937                 :     3410215 :   df_simulate_fixup_sets (bb, live);
    3938                 :             : }
    3939                 :             : 
    3940                 :             : 
    3941                 :             : /* Apply the artificial uses and defs at the top of BB in a backwards
    3942                 :             :    direction.  */
    3943                 :             : 
    3944                 :             : void
    3945                 :   121581742 : df_simulate_finalize_backwards (basic_block bb, bitmap live)
    3946                 :             : {
    3947                 :   121581742 :   df_ref def;
    3948                 :             : #ifdef EH_USES
    3949                 :             :   df_ref use;
    3950                 :             : #endif
    3951                 :   121581742 :   int bb_index = bb->index;
    3952                 :             : 
    3953                 :   248403617 :   FOR_EACH_ARTIFICIAL_DEF (def, bb_index)
    3954                 :     5240133 :     if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
    3955                 :     5240133 :       bitmap_clear_bit (live, DF_REF_REGNO (def));
    3956                 :             : 
    3957                 :             : #ifdef EH_USES
    3958                 :             :   FOR_EACH_ARTIFICIAL_USE (use, bb_index)
    3959                 :             :     if (DF_REF_FLAGS (use) & DF_REF_AT_TOP)
    3960                 :             :       bitmap_set_bit (live, DF_REF_REGNO (use));
    3961                 :             : #endif
    3962                 :   121581742 : }
    3963                 :             : /*----------------------------------------------------------------------------
    3964                 :             :    The following three functions are used only for FORWARDS scanning:
    3965                 :             :    i.e. they process the defs and the REG_DEAD and REG_UNUSED notes.
    3966                 :             :    Thus it is important to add the DF_NOTES problem to the stack of
    3967                 :             :    problems computed before using these functions.
    3968                 :             : 
    3969                 :             :    df_simulate_initialize_forwards should be called first with a
    3970                 :             :    bitvector copyied from the DF_LIVE_IN or DF_LR_IN.  Then
    3971                 :             :    df_simulate_one_insn_forwards should be called for each insn in
    3972                 :             :    the block, starting with the first one.
    3973                 :             :    ----------------------------------------------------------------------------*/
    3974                 :             : 
    3975                 :             : /* Initialize the LIVE bitmap, which should be copied from DF_LIVE_IN or
    3976                 :             :    DF_LR_IN for basic block BB, for forward scanning by marking artificial
    3977                 :             :    defs live.  */
    3978                 :             : 
    3979                 :             : void
    3980                 :    43935207 : df_simulate_initialize_forwards (basic_block bb, bitmap live)
    3981                 :             : {
    3982                 :    43935207 :   df_ref def;
    3983                 :    43935207 :   int bb_index = bb->index;
    3984                 :             : 
    3985                 :   123432630 :   FOR_EACH_ARTIFICIAL_DEF (def, bb_index)
    3986                 :    35562216 :     if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
    3987                 :     1465878 :       bitmap_set_bit (live, DF_REF_REGNO (def));
    3988                 :    43935207 : }
    3989                 :             : 
    3990                 :             : /* Simulate the forwards effects of INSN on the bitmap LIVE.  */
    3991                 :             : 
    3992                 :             : void
    3993                 :   343359765 : df_simulate_one_insn_forwards (basic_block bb, rtx_insn *insn, bitmap live)
    3994                 :             : {
    3995                 :   343359765 :   rtx link;
    3996                 :   343359765 :   if (! INSN_P (insn))
    3997                 :             :     return;
    3998                 :             : 
    3999                 :             :   /* Make sure that DF_NOTE really is an active df problem.  */
    4000                 :   343359765 :   gcc_assert (df_note);
    4001                 :             : 
    4002                 :             :   /* Note that this is the opposite as how the problem is defined, because
    4003                 :             :      in the LR problem defs _kill_ liveness.  However, they do so backwards,
    4004                 :             :      while here the scan is performed forwards!  So, first assume that the
    4005                 :             :      def is live, and if this is not true REG_UNUSED notes will rectify the
    4006                 :             :      situation.  */
    4007                 :   343359765 :   df_simulate_find_noclobber_defs (insn, live);
    4008                 :             : 
    4009                 :             :   /* Clear all of the registers that go dead.  */
    4010                 :   573946985 :   for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
    4011                 :             :     {
    4012                 :   230587220 :       switch (REG_NOTE_KIND (link))
    4013                 :             :         {
    4014                 :   141716055 :         case REG_DEAD:
    4015                 :   141716055 :         case REG_UNUSED:
    4016                 :   141716055 :           {
    4017                 :   141716055 :             rtx reg = XEXP (link, 0);
    4018                 :   141716055 :             bitmap_clear_range (live, REGNO (reg), REG_NREGS (reg));
    4019                 :             :           }
    4020                 :   141716055 :           break;
    4021                 :             :         default:
    4022                 :             :           break;
    4023                 :             :         }
    4024                 :             :     }
    4025                 :   343359765 :   df_simulate_fixup_sets (bb, live);
    4026                 :             : }
    4027                 :             : 
    4028                 :             : /* Used by the next two functions to encode information about the
    4029                 :             :    memory references we found.  */
    4030                 :             : #define MEMREF_NORMAL 1
    4031                 :             : #define MEMREF_VOLATILE 2
    4032                 :             : 
    4033                 :             : /* Return an OR of MEMREF_NORMAL or MEMREF_VOLATILE for the MEMs in X.  */
    4034                 :             : 
    4035                 :             : static int
    4036                 :     1508220 : find_memory (rtx_insn *insn)
    4037                 :             : {
    4038                 :     1508220 :   int flags = 0;
    4039                 :     1508220 :   subrtx_iterator::array_type array;
    4040                 :    10771942 :   FOR_EACH_SUBRTX (iter, array, PATTERN (insn), NONCONST)
    4041                 :             :     {
    4042                 :     9263722 :       const_rtx x = *iter;
    4043                 :     9263722 :       if (GET_CODE (x) == ASM_OPERANDS && MEM_VOLATILE_P (x))
    4044                 :           0 :         flags |= MEMREF_VOLATILE;
    4045                 :     9263722 :       else if (MEM_P (x))
    4046                 :             :         {
    4047                 :      147112 :           if (MEM_VOLATILE_P (x))
    4048                 :         464 :             flags |= MEMREF_VOLATILE;
    4049                 :      146648 :           else if (!MEM_READONLY_P (x))
    4050                 :      139733 :             flags |= MEMREF_NORMAL;
    4051                 :             :         }
    4052                 :             :     }
    4053                 :     1508220 :   return flags;
    4054                 :     1508220 : }
    4055                 :             : 
    4056                 :             : /* A subroutine of can_move_insns_across_p called through note_stores.
    4057                 :             :    DATA points to an integer in which we set either the bit for
    4058                 :             :    MEMREF_NORMAL or the bit for MEMREF_VOLATILE if we find a MEM
    4059                 :             :    of either kind.  */
    4060                 :             : 
    4061                 :             : static void
    4062                 :     1568599 : find_memory_stores (rtx x, const_rtx pat ATTRIBUTE_UNUSED,
    4063                 :             :                     void *data ATTRIBUTE_UNUSED)
    4064                 :             : {
    4065                 :     1568599 :   int *pflags = (int *)data;
    4066                 :     1568599 :   if (GET_CODE (x) == SUBREG)
    4067                 :           0 :     x = XEXP (x, 0);
    4068                 :             :   /* Treat stores to SP as stores to memory, this will prevent problems
    4069                 :             :      when there are references to the stack frame.  */
    4070                 :     1568599 :   if (x == stack_pointer_rtx)
    4071                 :        2306 :     *pflags |= MEMREF_VOLATILE;
    4072                 :     1568599 :   if (!MEM_P (x))
    4073                 :             :     return;
    4074                 :       65777 :   *pflags |= MEM_VOLATILE_P (x) ? MEMREF_VOLATILE : MEMREF_NORMAL;
    4075                 :             : }
    4076                 :             : 
    4077                 :             : /* Scan BB backwards, using df_simulate functions to keep track of
    4078                 :             :    lifetimes, up to insn POINT.  The result is stored in LIVE.  */
    4079                 :             : 
    4080                 :             : void
    4081                 :      625149 : simulate_backwards_to_point (basic_block bb, regset live, rtx point)
    4082                 :             : {
    4083                 :      625149 :   rtx_insn *insn;
    4084                 :      625149 :   bitmap_copy (live, df_get_live_out (bb));
    4085                 :      625149 :   df_simulate_initialize_backwards (bb, live);
    4086                 :             : 
    4087                 :             :   /* Scan and update life information until we reach the point we're
    4088                 :             :      interested in.  */
    4089                 :     1744318 :   for (insn = BB_END (bb); insn != point; insn = PREV_INSN (insn))
    4090                 :     1119169 :     df_simulate_one_insn_backwards (bb, insn, live);
    4091                 :      625149 : }
    4092                 :             : 
    4093                 :             : /* Return true if it is safe to move a group of insns, described by
    4094                 :             :    the range FROM to TO, backwards across another group of insns,
    4095                 :             :    described by ACROSS_FROM to ACROSS_TO.  It is assumed that there
    4096                 :             :    are no insns between ACROSS_TO and FROM, but they may be in
    4097                 :             :    different basic blocks; MERGE_BB is the block from which the
    4098                 :             :    insns will be moved.  The caller must pass in a regset MERGE_LIVE
    4099                 :             :    which specifies the registers live after TO.
    4100                 :             : 
    4101                 :             :    This function may be called in one of two cases: either we try to
    4102                 :             :    move identical instructions from all successor blocks into their
    4103                 :             :    predecessor, or we try to move from only one successor block.  If
    4104                 :             :    OTHER_BRANCH_LIVE is nonnull, it indicates that we're dealing with
    4105                 :             :    the second case.  It should contain a set of registers live at the
    4106                 :             :    end of ACROSS_TO which must not be clobbered by moving the insns.
    4107                 :             :    In that case, we're also more careful about moving memory references
    4108                 :             :    and trapping insns.
    4109                 :             : 
    4110                 :             :    We return false if it is not safe to move the entire group, but it
    4111                 :             :    may still be possible to move a subgroup.  PMOVE_UPTO, if nonnull,
    4112                 :             :    is set to point at the last moveable insn in such a case.  */
    4113                 :             : 
    4114                 :             : bool
    4115                 :      591612 : can_move_insns_across (rtx_insn *from, rtx_insn *to,
    4116                 :             :                        rtx_insn *across_from, rtx_insn *across_to,
    4117                 :             :                        basic_block merge_bb, regset merge_live,
    4118                 :             :                        regset other_branch_live, rtx_insn **pmove_upto)
    4119                 :             : {
    4120                 :      591612 :   rtx_insn *insn, *next, *max_to;
    4121                 :      591612 :   bitmap merge_set, merge_use, local_merge_live;
    4122                 :      591612 :   bitmap test_set, test_use;
    4123                 :      591612 :   unsigned i, fail = 0;
    4124                 :      591612 :   bitmap_iterator bi;
    4125                 :      591612 :   int memrefs_in_across = 0;
    4126                 :      591612 :   int mem_sets_in_across = 0;
    4127                 :      591612 :   bool trapping_insns_in_across = false;
    4128                 :             : 
    4129                 :      591612 :   if (pmove_upto != NULL)
    4130                 :      150487 :     *pmove_upto = NULL;
    4131                 :             : 
    4132                 :             :   /* Find real bounds, ignoring debug insns.  */
    4133                 :      596652 :   while (!NONDEBUG_INSN_P (from) && from != to)
    4134                 :        5040 :     from = NEXT_INSN (from);
    4135                 :      592616 :   while (!NONDEBUG_INSN_P (to) && from != to)
    4136                 :        1004 :     to = PREV_INSN (to);
    4137                 :             : 
    4138                 :             :   for (insn = across_to; ; insn = next)
    4139                 :             :     {
    4140                 :     1141929 :       if (CALL_P (insn))
    4141                 :             :         {
    4142                 :        1402 :           if (RTL_CONST_OR_PURE_CALL_P (insn))
    4143                 :             :             /* Pure functions can read from memory.  Const functions can
    4144                 :             :                read from arguments that the ABI has forced onto the stack.
    4145                 :             :                Neither sort of read can be volatile.  */
    4146                 :         324 :             memrefs_in_across |= MEMREF_NORMAL;
    4147                 :             :           else
    4148                 :             :             {
    4149                 :        1078 :               memrefs_in_across |= MEMREF_VOLATILE;
    4150                 :        1078 :               mem_sets_in_across |= MEMREF_VOLATILE;
    4151                 :             :             }
    4152                 :             :         }
    4153                 :     1141929 :       if (NONDEBUG_INSN_P (insn))
    4154                 :             :         {
    4155                 :     1131680 :           if (volatile_insn_p (PATTERN (insn)))
    4156                 :             :             return false;
    4157                 :     1131679 :           memrefs_in_across |= find_memory (insn);
    4158                 :     1131679 :           note_stores (insn, find_memory_stores, &mem_sets_in_across);
    4159                 :             :           /* This is used just to find sets of the stack pointer.  */
    4160                 :     1131679 :           memrefs_in_across |= mem_sets_in_across;
    4161                 :     1131679 :           trapping_insns_in_across |= may_trap_p (PATTERN (insn));
    4162                 :             :         }
    4163                 :     1141928 :       next = PREV_INSN (insn);
    4164                 :     1141928 :       if (insn == across_from)
    4165                 :             :         break;
    4166                 :             :     }
    4167                 :             : 
    4168                 :             :   /* Collect:
    4169                 :             :      MERGE_SET = set of registers set in MERGE_BB
    4170                 :             :      MERGE_USE = set of registers used in MERGE_BB and live at its top
    4171                 :             :      MERGE_LIVE = set of registers live at the point inside the MERGE
    4172                 :             :      range that we've reached during scanning
    4173                 :             :      TEST_SET = set of registers set between ACROSS_FROM and ACROSS_END.
    4174                 :             :      TEST_USE = set of registers used between ACROSS_FROM and ACROSS_END,
    4175                 :             :      and live before ACROSS_FROM.  */
    4176                 :             : 
    4177                 :      591611 :   merge_set = BITMAP_ALLOC (&reg_obstack);
    4178                 :      591611 :   merge_use = BITMAP_ALLOC (&reg_obstack);
    4179                 :      591611 :   local_merge_live = BITMAP_ALLOC (&reg_obstack);
    4180                 :      591611 :   test_set = BITMAP_ALLOC (&reg_obstack);
    4181                 :      591611 :   test_use = BITMAP_ALLOC (&reg_obstack);
    4182                 :             : 
    4183                 :             :   /* Compute the set of registers set and used in the ACROSS range.  */
    4184                 :      591611 :   if (other_branch_live != NULL)
    4185                 :      441125 :     bitmap_copy (test_use, other_branch_live);
    4186                 :      591611 :   df_simulate_initialize_backwards (merge_bb, test_use);
    4187                 :      591611 :   for (insn = across_to; ; insn = next)
    4188                 :             :     {
    4189                 :     1141928 :       if (NONDEBUG_INSN_P (insn))
    4190                 :             :         {
    4191                 :     1131679 :           df_simulate_find_defs (insn, test_set);
    4192                 :     1131679 :           df_simulate_defs (insn, test_use);
    4193                 :     1131679 :           df_simulate_uses (insn, test_use);
    4194                 :             :         }
    4195                 :     1141928 :       next = PREV_INSN (insn);
    4196                 :     1141928 :       if (insn == across_from)
    4197                 :             :         break;
    4198                 :             :     }
    4199                 :             : 
    4200                 :             :   /* Compute an upper bound for the amount of insns moved, by finding
    4201                 :             :      the first insn in MERGE that sets a register in TEST_USE, or uses
    4202                 :             :      a register in TEST_SET.  We also check for calls, trapping operations,
    4203                 :             :      and memory references.  */
    4204                 :             :   max_to = NULL;
    4205                 :             :   for (insn = from; ; insn = next)
    4206                 :             :     {
    4207                 :      661486 :       if (CALL_P (insn))
    4208                 :             :         break;
    4209                 :      645382 :       if (NOTE_P (insn) && NOTE_KIND (insn) == NOTE_INSN_EPILOGUE_BEG)
    4210                 :             :         break;
    4211                 :      645382 :       if (NONDEBUG_INSN_P (insn))
    4212                 :             :         {
    4213                 :      634206 :           if (may_trap_or_fault_p (PATTERN (insn))
    4214                 :      634206 :               && (trapping_insns_in_across
    4215                 :      138360 :                   || other_branch_live != NULL
    4216                 :        7381 :                   || volatile_insn_p (PATTERN (insn))))
    4217                 :             :             break;
    4218                 :             : 
    4219                 :             :           /* We cannot move memory stores past each other, or move memory
    4220                 :             :              reads past stores, at least not without tracking them and
    4221                 :             :              calling true_dependence on every pair.
    4222                 :             : 
    4223                 :             :              If there is no other branch and no memory references or
    4224                 :             :              sets in the ACROSS range, we can move memory references
    4225                 :             :              freely, even volatile ones.
    4226                 :             : 
    4227                 :             :              Otherwise, the rules are as follows: volatile memory
    4228                 :             :              references and stores can't be moved at all, and any type
    4229                 :             :              of memory reference can't be moved if there are volatile
    4230                 :             :              accesses or stores in the ACROSS range.  That leaves
    4231                 :             :              normal reads, which can be moved, as the trapping case is
    4232                 :             :              dealt with elsewhere.  */
    4233                 :      502826 :           if (other_branch_live != NULL || memrefs_in_across != 0)
    4234                 :             :             {
    4235                 :      376541 :               int mem_ref_flags = 0;
    4236                 :      376541 :               int mem_set_flags = 0;
    4237                 :      376541 :               note_stores (insn, find_memory_stores, &mem_set_flags);
    4238                 :      376541 :               mem_ref_flags = find_memory (insn);
    4239                 :             :               /* Catch sets of the stack pointer.  */
    4240                 :      376541 :               mem_ref_flags |= mem_set_flags;
    4241                 :             : 
    4242                 :      376541 :               if ((mem_ref_flags | mem_set_flags) & MEMREF_VOLATILE)
    4243                 :             :                 break;
    4244                 :      374275 :               if ((memrefs_in_across & MEMREF_VOLATILE) && mem_ref_flags != 0)
    4245                 :             :                 break;
    4246                 :      373711 :               if (mem_set_flags != 0
    4247                 :      343544 :                   || (mem_sets_in_across != 0 && mem_ref_flags != 0))
    4248                 :             :                 break;
    4249                 :             :             }
    4250                 :      469777 :           df_simulate_find_uses (insn, merge_use);
    4251                 :             :           /* We're only interested in uses which use a value live at
    4252                 :             :              the top, not one previously set in this block.  */
    4253                 :      469777 :           bitmap_and_compl_into (merge_use, merge_set);
    4254                 :      469777 :           df_simulate_find_defs (insn, merge_set);
    4255                 :      469777 :           if (bitmap_intersect_p (merge_set, test_use)
    4256                 :      469777 :               || bitmap_intersect_p (merge_use, test_set))
    4257                 :             :             break;
    4258                 :             :           max_to = insn;
    4259                 :             :         }
    4260                 :      328765 :       next = NEXT_INSN (insn);
    4261                 :      328765 :       if (insn == to)
    4262                 :             :         break;
    4263                 :             :     }
    4264                 :      591611 :   if (max_to != to)
    4265                 :      332735 :     fail = 1;
    4266                 :             : 
    4267                 :      591611 :   if (max_to == NULL_RTX || (fail && pmove_upto == NULL))
    4268                 :      329042 :     goto out;
    4269                 :             : 
    4270                 :             :   /* Now, lower this upper bound by also taking into account that
    4271                 :             :      a range of insns moved across ACROSS must not leave a register
    4272                 :             :      live at the end that will be clobbered in ACROSS.  We need to
    4273                 :             :      find a point where TEST_SET & LIVE == 0.
    4274                 :             : 
    4275                 :             :      Insns in the MERGE range that set registers which are also set
    4276                 :             :      in the ACROSS range may still be moved as long as we also move
    4277                 :             :      later insns which use the results of the set, and make the
    4278                 :             :      register dead again.  This is verified by the condition stated
    4279                 :             :      above.  We only need to test it for registers that are set in
    4280                 :             :      the moved region.
    4281                 :             : 
    4282                 :             :      MERGE_LIVE is provided by the caller and holds live registers after
    4283                 :             :      TO.  */
    4284                 :      262569 :   bitmap_copy (local_merge_live, merge_live);
    4285                 :      538005 :   for (insn = to; insn != max_to; insn = PREV_INSN (insn))
    4286                 :       12867 :     df_simulate_one_insn_backwards (merge_bb, insn, local_merge_live);
    4287                 :             : 
    4288                 :             :   /* We're not interested in registers that aren't set in the moved
    4289                 :             :      region at all.  */
    4290                 :      262569 :   bitmap_and_into (local_merge_live, merge_set);
    4291                 :        1998 :   for (;;)
    4292                 :             :     {
    4293                 :      264567 :       if (NONDEBUG_INSN_P (insn))
    4294                 :             :         {
    4295                 :      263803 :           if (!bitmap_intersect_p (test_set, local_merge_live))
    4296                 :             :             {
    4297                 :      222505 :               max_to = insn;
    4298                 :      222505 :               break;
    4299                 :             :             }
    4300                 :             : 
    4301                 :       41298 :           df_simulate_one_insn_backwards (merge_bb, insn,
    4302                 :             :                                           local_merge_live);
    4303                 :             :         }
    4304                 :       42062 :       if (insn == from)
    4305                 :             :         {
    4306                 :       40064 :           fail = 1;
    4307                 :       40064 :           goto out;
    4308                 :             :         }
    4309                 :        1998 :       insn = PREV_INSN (insn);
    4310                 :             :     }
    4311                 :             : 
    4312                 :      222505 :   if (max_to != to)
    4313                 :        3891 :     fail = 1;
    4314                 :             : 
    4315                 :      222505 :   if (pmove_upto)
    4316                 :       33852 :     *pmove_upto = max_to;
    4317                 :             : 
    4318                 :             :   /* For small register class machines, don't lengthen lifetimes of
    4319                 :             :      hard registers before reload.  */
    4320                 :      222505 :   if (! reload_completed
    4321                 :      222505 :       && targetm.small_register_classes_for_mode_p (VOIDmode))
    4322                 :             :     {
    4323                 :      364240 :       EXECUTE_IF_SET_IN_BITMAP (merge_set, 0, i, bi)
    4324                 :             :         {
    4325                 :      200839 :           if (i < FIRST_PSEUDO_REGISTER
    4326                 :       11211 :               && ! fixed_regs[i]
    4327                 :           0 :               && ! global_regs[i])
    4328                 :             :             {
    4329                 :             :               fail = 1;
    4330                 :             :               break;
    4331                 :             :             }
    4332                 :             :         }
    4333                 :             :     }
    4334                 :             : 
    4335                 :      591611 :  out:
    4336                 :      591611 :   BITMAP_FREE (merge_set);
    4337                 :      591611 :   BITMAP_FREE (merge_use);
    4338                 :      591611 :   BITMAP_FREE (local_merge_live);
    4339                 :      591611 :   BITMAP_FREE (test_set);
    4340                 :      591611 :   BITMAP_FREE (test_use);
    4341                 :             : 
    4342                 :      591611 :   return !fail;
    4343                 :             : }
    4344                 :             : 
    4345                 :             : 
    4346                 :             : /*----------------------------------------------------------------------------
    4347                 :             :    MULTIPLE DEFINITIONS
    4348                 :             : 
    4349                 :             :    Find the locations in the function reached by multiple definition sites
    4350                 :             :    for a live pseudo.  In and out bitvectors are built for each basic
    4351                 :             :    block.  They are restricted for efficiency to live registers.
    4352                 :             : 
    4353                 :             :    The gen and kill sets for the problem are obvious.  Together they
    4354                 :             :    include all defined registers in a basic block; the gen set includes
    4355                 :             :    registers where a partial or conditional or may-clobber definition is
    4356                 :             :    last in the BB, while the kill set includes registers with a complete
    4357                 :             :    definition coming last.  However, the computation of the dataflow
    4358                 :             :    itself is interesting.
    4359                 :             : 
    4360                 :             :    The idea behind it comes from SSA form's iterated dominance frontier
    4361                 :             :    criterion for inserting PHI functions.  Just like in that case, we can use
    4362                 :             :    the dominance frontier to find places where multiple definitions meet;
    4363                 :             :    a register X defined in a basic block BB1 has multiple definitions in
    4364                 :             :    basic blocks in BB1's dominance frontier.
    4365                 :             : 
    4366                 :             :    So, the in-set of a basic block BB2 is not just the union of the
    4367                 :             :    out-sets of BB2's predecessors, but includes some more bits that come
    4368                 :             :    from the basic blocks of whose dominance frontier BB2 is part (BB1 in
    4369                 :             :    the previous paragraph).  I called this set the init-set of BB2.
    4370                 :             : 
    4371                 :             :       (Note: I actually use the kill-set only to build the init-set.
    4372                 :             :       gen bits are anyway propagated from BB1 to BB2 by dataflow).
    4373                 :             : 
    4374                 :             :     For example, if you have
    4375                 :             : 
    4376                 :             :        BB1 : r10 = 0
    4377                 :             :              r11 = 0
    4378                 :             :              if <...> goto BB2 else goto BB3;
    4379                 :             : 
    4380                 :             :        BB2 : r10 = 1
    4381                 :             :              r12 = 1
    4382                 :             :              goto BB3;
    4383                 :             : 
    4384                 :             :        BB3 :
    4385                 :             : 
    4386                 :             :     you have BB3 in BB2's dominance frontier but not in BB1's, so that the
    4387                 :             :     init-set of BB3 includes r10 and r12, but not r11.  Note that we do
    4388                 :             :     not need to iterate the dominance frontier, because we do not insert
    4389                 :             :     anything like PHI functions there!  Instead, dataflow will take care of
    4390                 :             :     propagating the information to BB3's successors.
    4391                 :             :    ---------------------------------------------------------------------------*/
    4392                 :             : 
    4393                 :             : /* Private data used to verify the solution for this problem.  */
    4394                 :             : struct df_md_problem_data
    4395                 :             : {
    4396                 :             :   /* An obstack for the bitmaps we need for this problem.  */
    4397                 :             :   bitmap_obstack md_bitmaps;
    4398                 :             : };
    4399                 :             : 
    4400                 :             : /* Scratch var used by transfer functions.  This is used to do md analysis
    4401                 :             :    only for live registers.  */
    4402                 :             : static bitmap_head df_md_scratch;
    4403                 :             : 
    4404                 :             : 
    4405                 :             : static void
    4406                 :           0 : df_md_free_bb_info (basic_block bb ATTRIBUTE_UNUSED,
    4407                 :             :                     void *vbb_info)
    4408                 :             : {
    4409                 :           0 :   class df_md_bb_info *bb_info = (class df_md_bb_info *) vbb_info;
    4410                 :           0 :   if (bb_info)
    4411                 :             :     {
    4412                 :           0 :       bitmap_clear (&bb_info->kill);
    4413                 :           0 :       bitmap_clear (&bb_info->gen);
    4414                 :           0 :       bitmap_clear (&bb_info->init);
    4415                 :           0 :       bitmap_clear (&bb_info->in);
    4416                 :           0 :       bitmap_clear (&bb_info->out);
    4417                 :             :     }
    4418                 :           0 : }
    4419                 :             : 
    4420                 :             : 
    4421                 :             : /* Allocate or reset bitmaps for DF_MD. The solution bits are
    4422                 :             :    not touched unless the block is new.  */
    4423                 :             : 
    4424                 :             : static void
    4425                 :           0 : df_md_alloc (bitmap all_blocks)
    4426                 :             : {
    4427                 :           0 :   unsigned int bb_index;
    4428                 :           0 :   bitmap_iterator bi;
    4429                 :           0 :   struct df_md_problem_data *problem_data;
    4430                 :             : 
    4431                 :           0 :   df_grow_bb_info (df_md);
    4432                 :           0 :   if (df_md->problem_data)
    4433                 :             :     problem_data = (struct df_md_problem_data *) df_md->problem_data;
    4434                 :             :   else
    4435                 :             :     {
    4436                 :           0 :       problem_data = XNEW (struct df_md_problem_data);
    4437                 :           0 :       df_md->problem_data = problem_data;
    4438                 :           0 :       bitmap_obstack_initialize (&problem_data->md_bitmaps);
    4439                 :             :     }
    4440                 :           0 :   bitmap_initialize (&df_md_scratch, &problem_data->md_bitmaps);
    4441                 :             : 
    4442                 :           0 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
    4443                 :             :     {
    4444                 :           0 :       class df_md_bb_info *bb_info = df_md_get_bb_info (bb_index);
    4445                 :             :       /* When bitmaps are already initialized, just clear them.  */
    4446                 :           0 :       if (bb_info->init.obstack)
    4447                 :             :         {
    4448                 :           0 :           bitmap_clear (&bb_info->init);
    4449                 :           0 :           bitmap_clear (&bb_info->gen);
    4450                 :           0 :           bitmap_clear (&bb_info->kill);
    4451                 :           0 :           bitmap_clear (&bb_info->in);
    4452                 :           0 :           bitmap_clear (&bb_info->out);
    4453                 :             :         }
    4454                 :             :       else
    4455                 :             :         {
    4456                 :           0 :           bitmap_initialize (&bb_info->init, &problem_data->md_bitmaps);
    4457                 :           0 :           bitmap_initialize (&bb_info->gen, &problem_data->md_bitmaps);
    4458                 :           0 :           bitmap_initialize (&bb_info->kill, &problem_data->md_bitmaps);
    4459                 :           0 :           bitmap_initialize (&bb_info->in, &problem_data->md_bitmaps);
    4460                 :           0 :           bitmap_initialize (&bb_info->out, &problem_data->md_bitmaps);
    4461                 :             :         }
    4462                 :             :     }
    4463                 :             : 
    4464                 :           0 :   df_md->optional_p = true;
    4465                 :           0 : }
    4466                 :             : 
    4467                 :             : /* Add the effect of the top artificial defs of BB to the multiple definitions
    4468                 :             :    bitmap LOCAL_MD.  */
    4469                 :             : 
    4470                 :             : void
    4471                 :           0 : df_md_simulate_artificial_defs_at_top (basic_block bb, bitmap local_md)
    4472                 :             : {
    4473                 :           0 :   int bb_index = bb->index;
    4474                 :           0 :   df_ref def;
    4475                 :           0 :   FOR_EACH_ARTIFICIAL_DEF (def, bb_index)
    4476                 :           0 :     if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
    4477                 :             :       {
    4478                 :           0 :         unsigned int dregno = DF_REF_REGNO (def);
    4479                 :           0 :         if (DF_REF_FLAGS (def)
    4480                 :             :             & (DF_REF_PARTIAL | DF_REF_CONDITIONAL | DF_REF_MAY_CLOBBER))
    4481                 :           0 :           bitmap_set_bit (local_md, dregno);
    4482                 :             :         else
    4483                 :           0 :           bitmap_clear_bit (local_md, dregno);
    4484                 :             :       }
    4485                 :           0 : }
    4486                 :             : 
    4487                 :             : 
    4488                 :             : /* Add the effect of the defs of INSN to the reaching definitions bitmap
    4489                 :             :    LOCAL_MD.  */
    4490                 :             : 
    4491                 :             : void
    4492                 :           0 : df_md_simulate_one_insn (basic_block bb ATTRIBUTE_UNUSED, rtx_insn *insn,
    4493                 :             :                          bitmap local_md)
    4494                 :             : {
    4495                 :           0 :   df_ref def;
    4496                 :             : 
    4497                 :           0 :   FOR_EACH_INSN_DEF (def, insn)
    4498                 :             :     {
    4499                 :           0 :       unsigned int dregno = DF_REF_REGNO (def);
    4500                 :           0 :       if ((!(df->changeable_flags & DF_NO_HARD_REGS))
    4501                 :           0 :           || (dregno >= FIRST_PSEUDO_REGISTER))
    4502                 :             :         {
    4503                 :           0 :           if (DF_REF_FLAGS (def)
    4504                 :             :               & (DF_REF_PARTIAL | DF_REF_CONDITIONAL | DF_REF_MAY_CLOBBER))
    4505                 :           0 :            bitmap_set_bit (local_md, DF_REF_ID (def));
    4506                 :             :          else
    4507                 :           0 :            bitmap_clear_bit (local_md, DF_REF_ID (def));
    4508                 :             :         }
    4509                 :             :     }
    4510                 :           0 : }
    4511                 :             : 
    4512                 :             : static void
    4513                 :           0 : df_md_bb_local_compute_process_def (class df_md_bb_info *bb_info,
    4514                 :             :                                     df_ref def,
    4515                 :             :                                     int top_flag)
    4516                 :             : {
    4517                 :           0 :   bitmap_clear (&seen_in_insn);
    4518                 :             : 
    4519                 :           0 :   for (; def; def = DF_REF_NEXT_LOC (def))
    4520                 :             :     {
    4521                 :           0 :       unsigned int dregno = DF_REF_REGNO (def);
    4522                 :           0 :       if (((!(df->changeable_flags & DF_NO_HARD_REGS))
    4523                 :           0 :             || (dregno >= FIRST_PSEUDO_REGISTER))
    4524                 :           0 :           && top_flag == (DF_REF_FLAGS (def) & DF_REF_AT_TOP))
    4525                 :             :         {
    4526                 :           0 :           if (!bitmap_bit_p (&seen_in_insn, dregno))
    4527                 :             :             {
    4528                 :           0 :               if (DF_REF_FLAGS (def)
    4529                 :             :                   & (DF_REF_PARTIAL | DF_REF_CONDITIONAL | DF_REF_MAY_CLOBBER))
    4530                 :             :                 {
    4531                 :           0 :                   bitmap_set_bit (&bb_info->gen, dregno);
    4532                 :           0 :                   bitmap_clear_bit (&bb_info->kill, dregno);
    4533                 :             :                 }
    4534                 :             :               else
    4535                 :             :                 {
    4536                 :             :                   /* When we find a clobber and a regular def,
    4537                 :             :                      make sure the regular def wins.  */
    4538                 :           0 :                   bitmap_set_bit (&seen_in_insn, dregno);
    4539                 :           0 :                   bitmap_set_bit (&bb_info->kill, dregno);
    4540                 :           0 :                   bitmap_clear_bit (&bb_info->gen, dregno);
    4541                 :             :                 }
    4542                 :             :             }
    4543                 :             :         }
    4544                 :             :     }
    4545                 :           0 : }
    4546                 :             : 
    4547                 :             : 
    4548                 :             : /* Compute local multiple def info for basic block BB.  */
    4549                 :             : 
    4550                 :             : static void
    4551                 :           0 : df_md_bb_local_compute (unsigned int bb_index)
    4552                 :             : {
    4553                 :           0 :   basic_block bb = BASIC_BLOCK_FOR_FN (cfun, bb_index);
    4554                 :           0 :   class df_md_bb_info *bb_info = df_md_get_bb_info (bb_index);
    4555                 :           0 :   rtx_insn *insn;
    4556                 :             : 
    4557                 :             :   /* Artificials are only hard regs.  */
    4558                 :           0 :   if (!(df->changeable_flags & DF_NO_HARD_REGS))
    4559                 :           0 :     df_md_bb_local_compute_process_def (bb_info,
    4560                 :             :                                         df_get_artificial_defs (bb_index),
    4561                 :             :                                         DF_REF_AT_TOP);
    4562                 :             : 
    4563                 :           0 :   FOR_BB_INSNS (bb, insn)
    4564                 :             :     {
    4565                 :           0 :       unsigned int uid = INSN_UID (insn);
    4566                 :           0 :       if (!INSN_P (insn))
    4567                 :           0 :         continue;
    4568                 :             : 
    4569                 :           0 :       df_md_bb_local_compute_process_def (bb_info, DF_INSN_UID_DEFS (uid), 0);
    4570                 :             :     }
    4571                 :             : 
    4572                 :           0 :   if (!(df->changeable_flags & DF_NO_HARD_REGS))
    4573                 :           0 :     df_md_bb_local_compute_process_def (bb_info,
    4574                 :             :                                         df_get_artificial_defs (bb_index),
    4575                 :             :                                         0);
    4576                 :           0 : }
    4577                 :             : 
    4578                 :             : /* Compute local reaching def info for each basic block within BLOCKS.  */
    4579                 :             : 
    4580                 :             : static void
    4581                 :           0 : df_md_local_compute (bitmap all_blocks)
    4582                 :             : {
    4583                 :           0 :   unsigned int bb_index, df_bb_index;
    4584                 :           0 :   bitmap_iterator bi1, bi2;
    4585                 :           0 :   basic_block bb;
    4586                 :           0 :   bitmap_head *frontiers;
    4587                 :             : 
    4588                 :           0 :   bitmap_initialize (&seen_in_insn, &bitmap_default_obstack);
    4589                 :             : 
    4590                 :           0 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi1)
    4591                 :             :     {
    4592                 :           0 :       df_md_bb_local_compute (bb_index);
    4593                 :             :     }
    4594                 :             : 
    4595                 :           0 :   bitmap_release (&seen_in_insn);
    4596                 :             : 
    4597                 :           0 :   frontiers = XNEWVEC (bitmap_head, last_basic_block_for_fn (cfun));
    4598                 :           0 :   FOR_ALL_BB_FN (bb, cfun)
    4599                 :           0 :     bitmap_initialize (&frontiers[bb->index], &bitmap_default_obstack);
    4600                 :             : 
    4601                 :           0 :   compute_dominance_frontiers (frontiers);
    4602                 :             : 
    4603                 :             :   /* Add each basic block's kills to the nodes in the frontier of the BB.  */
    4604                 :           0 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi1)
    4605                 :             :     {
    4606                 :           0 :       bitmap kill = &df_md_get_bb_info (bb_index)->kill;
    4607                 :           0 :       EXECUTE_IF_SET_IN_BITMAP (&frontiers[bb_index], 0, df_bb_index, bi2)
    4608                 :             :         {
    4609                 :           0 :           basic_block bb = BASIC_BLOCK_FOR_FN (cfun, df_bb_index);
    4610                 :           0 :           if (bitmap_bit_p (all_blocks, df_bb_index))
    4611                 :           0 :             bitmap_ior_and_into (&df_md_get_bb_info (df_bb_index)->init, kill,
    4612                 :           0 :                                  df_get_live_in (bb));
    4613                 :             :         }
    4614                 :             :     }
    4615                 :             : 
    4616                 :           0 :   FOR_ALL_BB_FN (bb, cfun)
    4617                 :           0 :     bitmap_clear (&frontiers[bb->index]);
    4618                 :           0 :   free (frontiers);
    4619                 :           0 : }
    4620                 :             : 
    4621                 :             : 
    4622                 :             : /* Reset the global solution for recalculation.  */
    4623                 :             : 
    4624                 :             : static void
    4625                 :           0 : df_md_reset (bitmap all_blocks)
    4626                 :             : {
    4627                 :           0 :   unsigned int bb_index;
    4628                 :           0 :   bitmap_iterator bi;
    4629                 :             : 
    4630                 :           0 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
    4631                 :             :     {
    4632                 :           0 :       class df_md_bb_info *bb_info = df_md_get_bb_info (bb_index);
    4633                 :           0 :       gcc_assert (bb_info);
    4634                 :           0 :       bitmap_clear (&bb_info->in);
    4635                 :           0 :       bitmap_clear (&bb_info->out);
    4636                 :             :     }
    4637                 :           0 : }
    4638                 :             : 
    4639                 :             : static bool
    4640                 :           0 : df_md_transfer_function (int bb_index)
    4641                 :             : {
    4642                 :           0 :   basic_block bb = BASIC_BLOCK_FOR_FN (cfun, bb_index);
    4643                 :           0 :   class df_md_bb_info *bb_info = df_md_get_bb_info (bb_index);
    4644                 :           0 :   bitmap in = &bb_info->in;
    4645                 :           0 :   bitmap out = &bb_info->out;
    4646                 :           0 :   bitmap gen = &bb_info->gen;
    4647                 :           0 :   bitmap kill = &bb_info->kill;
    4648                 :             : 
    4649                 :             :   /* We need to use a scratch set here so that the value returned from this
    4650                 :             :      function invocation properly reflects whether the sets changed in a
    4651                 :             :      significant way; i.e. not just because the live set was anded in.  */
    4652                 :           0 :   bitmap_and (&df_md_scratch, gen, df_get_live_out (bb));
    4653                 :             : 
    4654                 :             :   /* Multiple definitions of a register are not relevant if it is not
    4655                 :             :      live.  Thus we trim the result to the places where it is live.  */
    4656                 :           0 :   bitmap_and_into (in, df_get_live_in (bb));
    4657                 :             : 
    4658                 :           0 :   return bitmap_ior_and_compl (out, &df_md_scratch, in, kill);
    4659                 :             : }
    4660                 :             : 
    4661                 :             : /* Initialize the solution bit vectors for problem.  */
    4662                 :             : 
    4663                 :             : static void
    4664                 :           0 : df_md_init (bitmap all_blocks)
    4665                 :             : {
    4666                 :           0 :   unsigned int bb_index;
    4667                 :           0 :   bitmap_iterator bi;
    4668                 :             : 
    4669                 :           0 :   EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
    4670                 :             :     {
    4671                 :           0 :       class df_md_bb_info *bb_info = df_md_get_bb_info (bb_index);
    4672                 :             : 
    4673                 :           0 :       bitmap_copy (&bb_info->in, &bb_info->init);
    4674                 :           0 :       df_md_transfer_function (bb_index);
    4675                 :             :     }
    4676                 :           0 : }
    4677                 :             : 
    4678                 :             : static void
    4679                 :           0 : df_md_confluence_0 (basic_block bb)
    4680                 :             : {
    4681                 :           0 :   class df_md_bb_info *bb_info = df_md_get_bb_info (bb->index);
    4682                 :           0 :   bitmap_copy (&bb_info->in, &bb_info->init);
    4683                 :           0 : }
    4684                 :             : 
    4685                 :             : /* In of target gets or of out of source.  */
    4686                 :             : 
    4687                 :             : static bool
    4688                 :           0 : df_md_confluence_n (edge e)
    4689                 :             : {
    4690                 :           0 :   bitmap op1 = &df_md_get_bb_info (e->dest->index)->in;
    4691                 :           0 :   bitmap op2 = &df_md_get_bb_info (e->src->index)->out;
    4692                 :             : 
    4693                 :           0 :   if (e->flags & EDGE_FAKE)
    4694                 :             :     return false;
    4695                 :             : 
    4696                 :           0 :   if (e->flags & EDGE_EH)
    4697                 :             :     {
    4698                 :             :       /* Conservatively treat partially-clobbered registers as surviving
    4699                 :             :          across the edge; they might or might not, depending on what mode
    4700                 :             :          they have.  */
    4701                 :           0 :       bitmap_view<HARD_REG_SET> eh_kills (eh_edge_abi.full_reg_clobbers ());
    4702                 :           0 :       return bitmap_ior_and_compl_into (op1, op2, eh_kills);
    4703                 :             :     }
    4704                 :             :   else
    4705                 :           0 :     return bitmap_ior_into (op1, op2);
    4706                 :             : }
    4707                 :             : 
    4708                 :             : /* Free all storage associated with the problem.  */
    4709                 :             : 
    4710                 :             : static void
    4711                 :           0 : df_md_free (void)
    4712                 :             : {
    4713                 :           0 :   struct df_md_problem_data *problem_data
    4714                 :           0 :     = (struct df_md_problem_data *) df_md->problem_data;
    4715                 :             : 
    4716                 :           0 :   bitmap_release (&df_md_scratch);
    4717                 :           0 :   bitmap_obstack_release (&problem_data->md_bitmaps);
    4718                 :           0 :   free (problem_data);
    4719                 :           0 :   df_md->problem_data = NULL;
    4720                 :             : 
    4721                 :           0 :   df_md->block_info_size = 0;
    4722                 :           0 :   free (df_md->block_info);
    4723                 :           0 :   df_md->block_info = NULL;
    4724                 :           0 :   free (df_md);
    4725                 :           0 : }
    4726                 :             : 
    4727                 :             : 
    4728                 :             : /* Debugging info at top of bb.  */
    4729                 :             : 
    4730                 :             : static void
    4731                 :           0 : df_md_top_dump (basic_block bb, FILE *file)
    4732                 :             : {
    4733                 :           0 :   class df_md_bb_info *bb_info = df_md_get_bb_info (bb->index);
    4734                 :           0 :   if (!bb_info)
    4735                 :             :     return;
    4736                 :             : 
    4737                 :           0 :   fprintf (file, ";; md  in  \t");
    4738                 :           0 :   df_print_regset (file, &bb_info->in);
    4739                 :           0 :   fprintf (file, ";; md  init  \t");
    4740                 :           0 :   df_print_regset (file, &bb_info->init);
    4741                 :           0 :   fprintf (file, ";; md  gen \t");
    4742                 :           0 :   df_print_regset (file, &bb_info->gen);
    4743                 :           0 :   fprintf (file, ";; md  kill \t");
    4744                 :           0 :   df_print_regset (file, &bb_info->kill);
    4745                 :             : }
    4746                 :             : 
    4747                 :             : /* Debugging info at bottom of bb.  */
    4748                 :             : 
    4749                 :             : static void
    4750                 :           0 : df_md_bottom_dump (basic_block bb, FILE *file)
    4751                 :             : {
    4752                 :           0 :   class df_md_bb_info *bb_info = df_md_get_bb_info (bb->index);
    4753                 :           0 :   if (!bb_info)
    4754                 :             :     return;
    4755                 :             : 
    4756                 :           0 :   fprintf (file, ";; md  out \t");
    4757                 :           0 :   df_print_regset (file, &bb_info->out);
    4758                 :             : }
    4759                 :             : 
    4760                 :             : static const struct df_problem problem_MD =
    4761                 :             : {
    4762                 :             :   DF_MD,                      /* Problem id.  */
    4763                 :             :   DF_FORWARD,                 /* Direction.  */
    4764                 :             :   df_md_alloc,                /* Allocate the problem specific data.  */
    4765                 :             :   df_md_reset,                /* Reset global information.  */
    4766                 :             :   df_md_free_bb_info,         /* Free basic block info.  */
    4767                 :             :   df_md_local_compute,        /* Local compute function.  */
    4768                 :             :   df_md_init,                 /* Init the solution specific data.  */
    4769                 :             :   df_worklist_dataflow,       /* Worklist solver.  */
    4770                 :             :   df_md_confluence_0,         /* Confluence operator 0.  */
    4771                 :             :   df_md_confluence_n,         /* Confluence operator n.  */
    4772                 :             :   df_md_transfer_function,    /* Transfer function.  */
    4773                 :             :   NULL,                       /* Finalize function.  */
    4774                 :             :   df_md_free,                 /* Free all of the problem information.  */
    4775                 :             :   df_md_free,                 /* Remove this problem from the stack of dataflow problems.  */
    4776                 :             :   NULL,                       /* Debugging.  */
    4777                 :             :   df_md_top_dump,             /* Debugging start block.  */
    4778                 :             :   df_md_bottom_dump,          /* Debugging end block.  */
    4779                 :             :   NULL,                       /* Debugging start insn.  */
    4780                 :             :   NULL,                       /* Debugging end insn.  */
    4781                 :             :   NULL,                       /* Incremental solution verify start.  */
    4782                 :             :   NULL,                       /* Incremental solution verify end.  */
    4783                 :             :   NULL,                       /* Dependent problem.  */
    4784                 :             :   sizeof (class df_md_bb_info),/* Size of entry of block_info array.  */
    4785                 :             :   TV_DF_MD,                   /* Timing variable.  */
    4786                 :             :   false                       /* Reset blocks on dropping out of blocks_to_analyze.  */
    4787                 :             : };
    4788                 :             : 
    4789                 :             : /* Create a new MD instance and add it to the existing instance
    4790                 :             :    of DF.  */
    4791                 :             : 
    4792                 :             : void
    4793                 :           0 : df_md_add_problem (void)
    4794                 :             : {
    4795                 :           0 :   df_add_problem (&problem_MD);
    4796                 :           0 : }
    4797                 :             : 
    4798                 :             : 
    4799                 :             : 
        

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.