LCOV - code coverage report
Current view: top level - gcc - cfg.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 90.9 % 22 20
Test Date: 2024-04-13 14:00:49 Functions: 100.0 % 2 2
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Control flow graph manipulation code header file.
       2                 :             :    Copyright (C) 2014-2024 Free Software Foundation, Inc.
       3                 :             : 
       4                 :             : This file is part of GCC.
       5                 :             : 
       6                 :             : GCC is free software; you can redistribute it and/or modify it under
       7                 :             : the terms of the GNU General Public License as published by the Free
       8                 :             : Software Foundation; either version 3, or (at your option) any later
       9                 :             : version.
      10                 :             : 
      11                 :             : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12                 :             : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13                 :             : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14                 :             : for more details.
      15                 :             : 
      16                 :             : You should have received a copy of the GNU General Public License
      17                 :             : along with GCC; see the file COPYING3.  If not see
      18                 :             : <http://www.gnu.org/licenses/>.  */
      19                 :             : 
      20                 :             : #ifndef GCC_CFG_H
      21                 :             : #define GCC_CFG_H
      22                 :             : 
      23                 :             : #include "dominance.h"
      24                 :             : 
      25                 :             : /* What sort of profiling information we have.  */
      26                 :             : enum profile_status_d
      27                 :             : {
      28                 :             :   PROFILE_ABSENT,
      29                 :             :   PROFILE_GUESSED,
      30                 :             :   PROFILE_READ,
      31                 :             :   PROFILE_LAST  /* Last value, used by profile streaming.  */
      32                 :             : };
      33                 :             : 
      34                 :             : /* A structure to group all the per-function control flow graph data.
      35                 :             :    The x_* prefixing is necessary because otherwise references to the
      36                 :             :    fields of this struct are interpreted as the defines for backward
      37                 :             :    source compatibility following the definition of this struct.  */
      38                 :             : struct GTY(()) control_flow_graph {
      39                 :             :   /* Block pointers for the exit and entry of a function.
      40                 :             :      These are always the head and tail of the basic block list.  */
      41                 :             :   basic_block x_entry_block_ptr;
      42                 :             :   basic_block x_exit_block_ptr;
      43                 :             : 
      44                 :             :   /* Index by basic block number, get basic block struct info.  */
      45                 :             :   vec<basic_block, va_gc> *x_basic_block_info;
      46                 :             : 
      47                 :             :   /* Number of basic blocks in this flow graph.  */
      48                 :             :   int x_n_basic_blocks;
      49                 :             : 
      50                 :             :   /* Number of edges in this flow graph.  */
      51                 :             :   int x_n_edges;
      52                 :             : 
      53                 :             :   /* The first free basic block number.  */
      54                 :             :   int x_last_basic_block;
      55                 :             : 
      56                 :             :   /* UIDs for LABEL_DECLs.  */
      57                 :             :   int last_label_uid;
      58                 :             : 
      59                 :             :   /* Mapping of labels to their associated blocks.  At present
      60                 :             :      only used for the gimple CFG.  */
      61                 :             :   vec<basic_block, va_gc> *x_label_to_block_map;
      62                 :             : 
      63                 :             :   enum profile_status_d x_profile_status;
      64                 :             : 
      65                 :             :   /* Whether the dominators and the postdominators are available.  */
      66                 :             :   enum dom_state x_dom_computed[2];
      67                 :             : 
      68                 :             :   /* Number of basic blocks in the dominance tree.  */
      69                 :             :   unsigned x_n_bbs_in_dom_tree[2];
      70                 :             : 
      71                 :             :   /* Maximal number of entities in the single jumptable.  Used to estimate
      72                 :             :      final flowgraph size.  */
      73                 :             :   int max_jumptable_ents;
      74                 :             : 
      75                 :             :   /* Maximal count of BB in function.  */
      76                 :             :   profile_count count_max;
      77                 :             : 
      78                 :             :   /* Dynamically allocated edge/bb flags.  */
      79                 :             :   int edge_flags_allocated;
      80                 :             :   int bb_flags_allocated;
      81                 :             : 
      82                 :             :   /* Set if the profile is computed on every edge and basic block.  */
      83                 :             :   bool full_profile;
      84                 :             : };
      85                 :             : 
      86                 :             : 
      87                 :             : extern void init_flow (function *);
      88                 :             : extern void free_cfg (function *);
      89                 :             : extern basic_block alloc_block (void);
      90                 :             : extern void link_block (basic_block, basic_block);
      91                 :             : extern void unlink_block (basic_block);
      92                 :             : extern void compact_blocks (void);
      93                 :             : extern void expunge_block (basic_block);
      94                 :             : extern edge unchecked_make_edge (basic_block, basic_block, int);
      95                 :             : extern edge cached_make_edge (sbitmap, basic_block, basic_block, int);
      96                 :             : extern edge make_edge (basic_block, basic_block, int);
      97                 :             : extern edge make_single_succ_edge (basic_block, basic_block, int);
      98                 :             : extern void remove_edge_raw (edge);
      99                 :             : extern void redirect_edge_succ (edge, basic_block);
     100                 :             : extern void redirect_edge_pred (edge, basic_block);
     101                 :             : extern void clear_bb_flags (void);
     102                 :             : extern void dump_edge_info (FILE *, edge, dump_flags_t, int);
     103                 :             : extern void debug (edge_def &ref);
     104                 :             : extern void debug (edge_def *ptr);
     105                 :             : extern void alloc_aux_for_blocks (int);
     106                 :             : extern void clear_aux_for_blocks (void);
     107                 :             : extern void free_aux_for_blocks (void);
     108                 :             : extern void alloc_aux_for_edge (edge, int);
     109                 :             : extern void alloc_aux_for_edges (int);
     110                 :             : extern void clear_aux_for_edges (void);
     111                 :             : extern void free_aux_for_edges (void);
     112                 :             : extern void debug_bb (basic_block);
     113                 :             : extern basic_block debug_bb_n (int);
     114                 :             : extern void debug_bb (basic_block, dump_flags_t);
     115                 :             : extern basic_block debug_bb_n (int, dump_flags_t);
     116                 :             : extern void dump_bb_info (FILE *, basic_block, int, dump_flags_t, bool, bool);
     117                 :             : extern void brief_dump_cfg (FILE *, dump_flags_t);
     118                 :             : extern void set_edge_probability_and_rescale_others (edge, profile_probability);
     119                 :             : extern void update_bb_profile_for_threading (basic_block, profile_count, edge);
     120                 :             : extern void scale_bbs_frequencies_profile_count (basic_block *, int,
     121                 :             :                                              profile_count, profile_count);
     122                 :             : extern void scale_bbs_frequencies (basic_block *, int, profile_probability);
     123                 :             : extern void initialize_original_copy_tables (void);
     124                 :             : extern void reset_original_copy_tables (void);
     125                 :             : extern void free_original_copy_tables (void);
     126                 :             : extern bool original_copy_tables_initialized_p (void);
     127                 :             : extern void set_bb_original (basic_block, basic_block);
     128                 :             : extern basic_block get_bb_original (basic_block);
     129                 :             : extern void set_bb_copy (basic_block, basic_block);
     130                 :             : extern basic_block get_bb_copy (basic_block);
     131                 :             : void set_loop_copy (class loop *, class loop *);
     132                 :             : class loop *get_loop_copy (class loop *);
     133                 :             : void scale_strictly_dominated_blocks (basic_block,
     134                 :             :                                       profile_count, profile_count);
     135                 :             : 
     136                 :             : /* Generic RAII class to allocate a bit from storage of integer type T.
     137                 :             :    The allocated bit is accessible as mask with the single bit set
     138                 :             :    via the conversion operator to T.  */
     139                 :             : 
     140                 :             : template <class T>
     141                 :             : class auto_flag
     142                 :             : {
     143                 :             : public:
     144                 :             :   /* static assert T is integer type of max HOST_WIDE_INT precision.  */
     145                 :   380547364 :   auto_flag (T *sptr)
     146                 :             :     {
     147                 :   380547364 :       m_sptr = sptr;
     148                 :   380547364 :       int free_bit = ffs_hwi (~*sptr);
     149                 :             :       /* If there are no unset bits... */
     150                 :   380547364 :       if (free_bit == 0)
     151                 :           0 :         gcc_unreachable ();
     152                 :   380547364 :       m_flag = HOST_WIDE_INT_1U << (free_bit - 1);
     153                 :             :       /* ...or if T is signed and thus the complement is sign-extended,
     154                 :             :          check if we ran out of bits.  We could spare us this bit
     155                 :             :          if we could use C++11 std::make_unsigned<T>::type to pass
     156                 :             :          ~*sptr to ffs_hwi.  */
     157                 :   380547364 :       if (m_flag == 0)
     158                 :           0 :         gcc_unreachable ();
     159                 :   380547364 :       gcc_checking_assert ((*sptr & m_flag) == 0);
     160                 :   380547364 :       *sptr |= m_flag;
     161                 :   380547364 :     }
     162                 :   380547364 :   ~auto_flag ()
     163                 :             :     {
     164                 :   380547364 :       gcc_checking_assert ((*m_sptr & m_flag) == m_flag);
     165                 :   380547364 :       *m_sptr &= ~m_flag;
     166                 :   380547364 :     }
     167                 :  4930493592 :   operator T () const { return m_flag; }
     168                 :             : private:
     169                 :             :   T *m_sptr;
     170                 :             :   T m_flag;
     171                 :             : };
     172                 :             : 
     173                 :             : /* RAII class to allocate an edge flag for temporary use.  You have
     174                 :             :    to clear the flag from all edges when you are finished using it.  */
     175                 :             : 
     176                 :    54402250 : class auto_edge_flag : public auto_flag<int>
     177                 :             : {
     178                 :             : public:
     179                 :    54402250 :   auto_edge_flag (function *fun)
     180                 :    54402250 :     : auto_flag<int> (&fun->cfg->edge_flags_allocated) {}
     181                 :             : };
     182                 :             : 
     183                 :             : /* RAII class to allocate a bb flag for temporary use.  You have
     184                 :             :    to clear the flag from all edges when you are finished using it.  */
     185                 :   326145114 : class auto_bb_flag : public auto_flag<int>
     186                 :             : {
     187                 :             : public:
     188                 :   326145114 :   auto_bb_flag (function *fun)
     189                 :   326145114 :     : auto_flag<int> (&fun->cfg->bb_flags_allocated) {}
     190                 :             : };
     191                 :             : 
     192                 :             : #endif /* GCC_CFG_H */
        

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.