LCOV - code coverage report
Current view: top level - gcc/analyzer - state-purge.h (source / functions) Hit Total Coverage
Test: gcc.info Lines: 25 25 100.0 %
Date: 2020-03-28 11:57:23 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* Classes for purging state at function_points.
       2                 :            :    Copyright (C) 2019-2020 Free Software Foundation, Inc.
       3                 :            :    Contributed by David Malcolm <dmalcolm@redhat.com>.
       4                 :            : 
       5                 :            : This file is part of GCC.
       6                 :            : 
       7                 :            : GCC is free software; you can redistribute it and/or modify it
       8                 :            : under the terms of the GNU General Public License as published by
       9                 :            : the Free Software Foundation; either version 3, or (at your option)
      10                 :            : any later version.
      11                 :            : 
      12                 :            : GCC is distributed in the hope that it will be useful, but
      13                 :            : WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :            : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15                 :            : General Public License for more details.
      16                 :            : 
      17                 :            : You should have received a copy of the GNU General Public License
      18                 :            : along with GCC; see the file COPYING3.  If not see
      19                 :            : <http://www.gnu.org/licenses/>.  */
      20                 :            : 
      21                 :            : #ifndef GCC_ANALYZER_STATE_PURGE_H
      22                 :            : #define GCC_ANALYZER_STATE_PURGE_H
      23                 :            : 
      24                 :            : /* Hash traits for function_point.  */
      25                 :            : 
      26                 :            : template <> struct default_hash_traits<function_point>
      27                 :            : : public pod_hash_traits<function_point>
      28                 :            : {
      29                 :            :   static const bool empty_zero_p = false;
      30                 :            : };
      31                 :            : 
      32                 :            : template <>
      33                 :            : inline hashval_t
      34                 :     446626 : pod_hash_traits<function_point>::hash (value_type v)
      35                 :            : {
      36                 :     446626 :   return v.hash ();
      37                 :            : }
      38                 :            : 
      39                 :            : template <>
      40                 :            : inline bool
      41                 :     412431 : pod_hash_traits<function_point>::equal (const value_type &existing,
      42                 :            :                                  const value_type &candidate)
      43                 :            : {
      44                 :     991891 :   return existing == candidate;
      45                 :            : }
      46                 :            : template <>
      47                 :            : inline void
      48                 :            : pod_hash_traits<function_point>::mark_deleted (value_type &v)
      49                 :            : {
      50                 :            :   v = function_point::deleted ();
      51                 :            : }
      52                 :            : template <>
      53                 :            : inline void
      54                 :     103463 : pod_hash_traits<function_point>::mark_empty (value_type &v)
      55                 :            : {
      56                 :     103463 :   v = function_point::empty ();
      57                 :            : }
      58                 :            : template <>
      59                 :            : inline bool
      60                 :     442293 : pod_hash_traits<function_point>::is_deleted (value_type v)
      61                 :            : {
      62                 :     442293 :   return v.get_kind () == PK_DELETED;
      63                 :            : }
      64                 :            : template <>
      65                 :            : inline bool
      66                 :    1217100 : pod_hash_traits<function_point>::is_empty (value_type v)
      67                 :            : {
      68                 :    1098100 :   return v.get_kind () == PK_EMPTY;
      69                 :            : }
      70                 :            : 
      71                 :            : namespace ana {
      72                 :            : 
      73                 :            : /* The result of analyzing which SSA names can be purged from state at
      74                 :            :    different points in the program, so that we can simplify program_state
      75                 :            :    objects, in the hope of reducing state-blowup.  */
      76                 :            : 
      77                 :            : class state_purge_map : public log_user
      78                 :            : {
      79                 :            : public:
      80                 :            :   typedef ordered_hash_map<tree, state_purge_per_ssa_name *> map_t;
      81                 :            :   typedef map_t::iterator iterator;
      82                 :            : 
      83                 :            :   state_purge_map (const supergraph &sg, logger *logger);
      84                 :            :   ~state_purge_map ();
      85                 :            : 
      86                 :      84528 :   const state_purge_per_ssa_name &get_data_for_ssa_name (tree name) const
      87                 :            :   {
      88                 :      84528 :     gcc_assert (TREE_CODE (name) == SSA_NAME);
      89                 :      84528 :     if (tree var = SSA_NAME_VAR (name))
      90                 :      66735 :       if (TREE_CODE (var) == VAR_DECL)
      91                 :      40884 :         gcc_assert (!VAR_DECL_IS_VIRTUAL_OPERAND (var));
      92                 :            : 
      93                 :      84528 :     state_purge_per_ssa_name **slot
      94                 :      84528 :       = const_cast <map_t&> (m_map).get (name);
      95                 :      84528 :     return **slot;
      96                 :            :   }
      97                 :            : 
      98                 :      12036 :   const supergraph &get_sg () const { return m_sg; }
      99                 :            : 
     100                 :         49 :   iterator begin () const { return m_map.begin (); }
     101                 :       2352 :   iterator end () const { return m_map.end (); }
     102                 :            : 
     103                 :            : private:
     104                 :            :   DISABLE_COPY_AND_ASSIGN (state_purge_map);
     105                 :            : 
     106                 :            :   const supergraph &m_sg;
     107                 :            :   map_t m_map;
     108                 :            : };
     109                 :            : 
     110                 :            : /* The part of a state_purge_map relating to a specific SSA name.
     111                 :            : 
     112                 :            :    The result of analyzing a given SSA name, recording which
     113                 :            :    function_points need to retain state information about it to handle
     114                 :            :    their successor states, so that we can simplify program_state objects,
     115                 :            :    in the hope of reducing state-blowup.  */
     116                 :            : 
     117                 :       4382 : class state_purge_per_ssa_name
     118                 :            : {
     119                 :            : public:
     120                 :            :   state_purge_per_ssa_name (const state_purge_map &map,
     121                 :            :                             tree name,
     122                 :            :                             function *fun);
     123                 :            : 
     124                 :            :   bool needed_at_point_p (const function_point &point) const;
     125                 :            : 
     126                 :       1127 :   function *get_function () const { return m_fun; }
     127                 :            : 
     128                 :            : private:
     129                 :            :   static function_point before_use_stmt (const state_purge_map &map,
     130                 :            :                                          const gimple *use_stmt);
     131                 :            : 
     132                 :            :   void add_to_worklist (const function_point &point,
     133                 :            :                         auto_vec<function_point> *worklist,
     134                 :            :                         logger *logger);
     135                 :            : 
     136                 :            :   void process_point (const function_point &point,
     137                 :            :                       auto_vec<function_point> *worklist,
     138                 :            :                       const state_purge_map &map);
     139                 :            : 
     140                 :            :   typedef hash_set<function_point> point_set_t;
     141                 :            :   point_set_t m_points_needing_name;
     142                 :            :   tree m_name;
     143                 :            :   function *m_fun;
     144                 :            : };
     145                 :            : 
     146                 :            : /* Subclass of dot_annotator for use by -fdump-analyzer-state-purge.
     147                 :            :    Annotate the .dot output with state-purge information.  */
     148                 :            : 
     149                 :          1 : class state_purge_annotator : public dot_annotator
     150                 :            : {
     151                 :            : public:
     152                 :          1 :   state_purge_annotator (const state_purge_map *map) : m_map (map) {}
     153                 :            : 
     154                 :            :   bool add_node_annotations (graphviz_out *gv, const supernode &n, bool)
     155                 :            :     const FINAL OVERRIDE;
     156                 :            : 
     157                 :            :   void add_stmt_annotations (graphviz_out *gv, const gimple *stmt,
     158                 :            :                              bool within_row)
     159                 :            :     const FINAL OVERRIDE;
     160                 :            : 
     161                 :            : private:
     162                 :            :   const state_purge_map *m_map;
     163                 :            : };
     164                 :            : 
     165                 :            : } // namespace ana
     166                 :            : 
     167                 :            : #endif /* GCC_ANALYZER_STATE_PURGE_H */

Generated by: LCOV version 1.0

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 --enable-host-shared. GCC test suite is run with the built compiler.