GCC Middle and Back End API Reference
state-purge.h
Go to the documentation of this file.
1/* Classes for purging state at function_points.
2 Copyright (C) 2019-2024 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along 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
26template <> struct default_hash_traits<function_point>
27: public pod_hash_traits<function_point>
28{
29 static const bool empty_zero_p = false;
30};
31
32template <>
33inline hashval_t
35{
36 return v.hash ();
37}
38
39template <>
40inline bool
42 const value_type &candidate)
43{
44 return existing == candidate;
45}
46template <>
47inline void
49{
50 v = function_point::deleted ();
51}
52template <>
53inline void
55{
56 v = function_point::empty ();
57}
58template <>
59inline bool
61{
62 return v.get_kind () == PK_DELETED;
63}
64template <>
65inline bool
67{
68 return v.get_kind () == PK_EMPTY;
69}
70
71namespace ana {
72
73/* The result of analyzing which decls and 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
78{
79public:
81 typedef ssa_map_t::iterator ssa_iterator;
82
84 typedef decl_map_t::iterator decl_iterator;
85
88 logger *logger);
90
92 {
93 gcc_assert (TREE_CODE (name) == SSA_NAME);
94 if (tree var = SSA_NAME_VAR (name))
95 if (TREE_CODE (var) == VAR_DECL)
97
99 = const_cast <ssa_map_t&> (m_ssa_map).get (name);
100 return **slot;
101 }
102
104 {
106 || TREE_CODE (decl) == PARM_DECL
107 || TREE_CODE (decl) == RESULT_DECL);
109 = const_cast <decl_map_t&> (m_decl_map).get (decl))
110 return *slot;
111 else
112 return NULL;
113 }
114
117
118 const supergraph &get_sg () const { return m_sg; }
119
120 ssa_iterator begin_ssas () const { return m_ssa_map.begin (); }
121 ssa_iterator end_ssas () const { return m_ssa_map.end (); }
122
124 decl_iterator end_decls () const { return m_decl_map.end (); }
125
126private:
128
132};
133
134 /* Base class for state_purge_per_ssa_name and state_purge_per_decl. */
135
137{
138public:
139 const function &get_function () const { return m_fun; }
140 tree get_fndecl () const { return m_fun.decl; }
141
142protected:
144
146 : m_fun (fun)
147 {
148 }
149
150private:
152};
153
154/* The part of a state_purge_map relating to a specific SSA name.
155
156 The result of analyzing a given SSA name, recording which
157 function_points need to retain state information about it to handle
158 their successor states, so that we can simplify program_state objects,
159 in the hope of reducing state-blowup. */
160
185
186/* The part of a state_purge_map relating to a specific decl.
187
188 Analogous to state_purge_per_ssa_name, but for local decls.
189
190 This is more involved than the SSA name case, because we also need
191 to handle pointers and components. */
192
230
231/* Subclass of dot_annotator for use by -fdump-analyzer-state-purge.
232 Annotate the .dot output with state-purge information. */
233
235{
236public:
238
240 const final override;
241
243 bool within_row)
244 const final override;
245
246private:
248 const function_point &point,
249 bool within_table) const;
250
252};
253
254} // namespace ana
255
256#endif /* GCC_ANALYZER_STATE_PURGE_H */
Definition supergraph.h:599
Definition program-point.h:73
Definition analyzer-logging.h:147
Definition analyzer-logging.h:34
Definition region-model-manager.h:32
Definition region-model.h:258
Definition state-purge.h:235
void print_needed(graphviz_out *gv, const function_point &point, bool within_table) const
void add_stmt_annotations(graphviz_out *gv, const gimple *stmt, bool within_row) const final override
bool add_node_annotations(graphviz_out *gv, const supernode &n, bool) const final override
const state_purge_map * m_map
Definition state-purge.h:251
state_purge_annotator(const state_purge_map *map)
Definition state-purge.h:237
Definition state-purge.h:78
state_purge_per_decl & get_or_create_data_for_decl(const function &fun, tree decl)
ssa_iterator end_ssas() const
Definition state-purge.h:121
decl_iterator end_decls() const
Definition state-purge.h:124
const supergraph & m_sg
Definition state-purge.h:129
state_purge_map(const supergraph &sg, region_model_manager *mgr, logger *logger)
ordered_hash_map< tree, state_purge_per_ssa_name * > ssa_map_t
Definition state-purge.h:80
decl_map_t::iterator decl_iterator
Definition state-purge.h:84
ssa_map_t::iterator ssa_iterator
Definition state-purge.h:81
ssa_iterator begin_ssas() const
Definition state-purge.h:120
const state_purge_per_ssa_name & get_data_for_ssa_name(tree name) const
Definition state-purge.h:91
ordered_hash_map< tree, state_purge_per_decl * > decl_map_t
Definition state-purge.h:83
const supergraph & get_sg() const
Definition state-purge.h:118
ssa_map_t m_ssa_map
Definition state-purge.h:130
decl_iterator begin_decls() const
Definition state-purge.h:123
const state_purge_per_decl * get_any_data_for_decl(tree decl) const
Definition state-purge.h:103
DISABLE_COPY_AND_ASSIGN(state_purge_map)
decl_map_t m_decl_map
Definition state-purge.h:131
Definition state-purge.h:194
point_set_t m_points_needing_decl
Definition state-purge.h:226
point_set_t m_points_taking_address
Definition state-purge.h:227
state_purge_per_decl(const state_purge_map &map, tree decl, const function &fun)
void process_worklists(const state_purge_map &map, region_model_manager *mgr)
void process_point_forwards(const function_point &point, auto_vec< function_point > *worklist, point_set_t *seen, const state_purge_map &map)
void add_to_worklist(const function_point &point, auto_vec< function_point > *worklist, point_set_t *seen, logger *logger)
void add_pointed_to_at(const function_point &point)
bool needed_at_point_p(const function_point &point) const
void add_needed_at(const function_point &point)
tree m_decl
Definition state-purge.h:228
static function_point before_use_stmt(const state_purge_map &map, const gimple *use_stmt)
void process_point_backwards(const function_point &point, auto_vec< function_point > *worklist, point_set_t *seen, const state_purge_map &map, const region_model &model)
Definition state-purge.h:162
point_set_t m_points_needing_name
Definition state-purge.h:182
state_purge_per_ssa_name(const state_purge_map &map, tree name, const function &fun)
void process_point(const function_point &point, auto_vec< function_point > *worklist, const state_purge_map &map)
static function_point before_use_stmt(const state_purge_map &map, const gimple *use_stmt)
bool needed_at_point_p(const function_point &point) const
void add_to_worklist(const function_point &point, auto_vec< function_point > *worklist, logger *logger)
tree m_name
Definition state-purge.h:183
Definition state-purge.h:137
const function & get_function() const
Definition state-purge.h:139
hash_set< function_point > point_set_t
Definition state-purge.h:143
state_purge_per_tree(const function &fun)
Definition state-purge.h:145
tree get_fndecl() const
Definition state-purge.h:140
const function & m_fun
Definition state-purge.h:151
Definition supergraph.h:109
Definition supergraph.h:235
Definition exploded-graph.h:723
Definition vec.h:1656
Definition graphviz.h:29
Definition hash-set.h:37
Definition ordered-hash-map.h:35
iterator begin() const
Definition ordered-hash-map.h:183
iterator end() const
Definition ordered-hash-map.h:190
Definition lra-spills.cc:101
union tree_node * tree
Definition coretypes.h:97
static struct string2counter_map map[debug_counter_number_of_counters]
Definition dbgcnt.cc:39
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
Definition access-diagram.h:30
@ PK_EMPTY
Definition program-point.h:42
@ PK_DELETED
Definition program-point.h:43
Definition genautomata.cc:499
Definition hash-traits.h:466
Definition function.h:249
tree decl
Definition function.h:280
Definition gimple.h:225
Definition analyzer.h:491
static void mark_deleted(Type &)
static bool is_empty(Type)
static bool equal(const value_type &existing, const value_type &candidate)
static bool is_deleted(Type)
static hashval_t hash(value_type)
static void mark_empty(Type &)
#define NULL
Definition system.h:50
#define gcc_assert(EXPR)
Definition system.h:821
static tree candidate(unsigned uid)
Definition tree-sra.cc:325
#define SSA_NAME_VAR(NODE)
Definition tree.h:2079
#define VAR_DECL_IS_VIRTUAL_OPERAND(NODE)
Definition tree.h:3303
#define TREE_CODE(NODE)
Definition tree.h:324