GCC Middle and Back End API Reference
call-summary.h
Go to the documentation of this file.
1/* Classes for working with summaries of function calls.
2 Copyright (C) 2022 David Malcolm <dmalcolm@redhat.com>.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 3, or (at your option)
9any later version.
10
11GCC is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
19
20#ifndef GCC_ANALYZER_CALL_SUMMARY_H
21#define GCC_ANALYZER_CALL_SUMMARY_H
22
23#include "call-details.h"
24
25namespace ana {
26
27/* A class summarizing one particular outcome of a function that
28 we've already analyzed.
29 This lets us efficiently replay the analysis when we see calls
30 to the function, providing an approximation of the behavior of
31 the function without having to execute within the function itself. */
32
34{
35public:
37 const exploded_node *enode)
38 : m_per_fn_data (per_fn_data),
39 m_enode (enode)
40 {}
41 const program_state &get_state () const;
42 tree get_fndecl () const;
43
44 label_text get_desc () const;
45
46 void dump_to_logger (logger &) const;
47 void dump () const;
48
49 std::unique_ptr<text_art::tree_widget>
51
52private:
54
56 const exploded_node *const m_enode;
57};
58
59/* A class for handling replaying a specific call summary at
60 a specific call site.
61
62 Supports remapping svalues and regions, e.g. remapping
63 INIT_VAL(param of callee)
64 to:
65 whatever that argument is at the call site. */
66
68{
69public:
71 const function &called_fn,
72 call_summary &summary,
74
75 const call_details &get_call_details () const { return m_cd; }
76 const gcall &get_call_stmt () const { return m_cd.get_call_stmt (); }
78 region_model_context *get_ctxt () const { return m_cd.get_ctxt (); }
80
81 const extrinsic_state &get_ext_state () const { return m_ext_state; }
82
85
88
91
92 template <typename ConcreteValueType>
95
96 void add_svalue_mapping (const svalue *summary_sval,
97 const svalue *caller_sval);
98 void add_region_mapping (const region *summary_sval,
99 const region *caller_sval);
100
101 void dump_to_logger (logger &) const;
102 void dump () const;
103
104 std::unique_ptr<text_art::tree_widget>
106
107private:
109
112
113 template <typename ConcreteValueType>
116
120
121 // Mapping from svalues in summary to svalues for callsite:
122 typedef hash_map <const svalue *, const svalue *> svalue_map_t;
124
125 // Mapping from regions in summary to regions for callsite:
126 typedef hash_map <const region *, const region *> region_map_t;
128};
129
130} // namespace ana
131
132#endif /* GCC_ANALYZER_CALL_SUMMARY_H */
Definition call-details.h:32
region_model_manager * get_manager() const
region_model_context * get_ctxt() const
Definition call-details.h:40
const gcall & get_call_stmt() const
Definition call-details.h:61
region_model * get_model() const
Definition call-details.h:38
void add_region_mapping(const region *summary_sval, const region *caller_sval)
const symbolic::bit_vector * convert_bit_vector_from_summary(const symbolic::bit_vector &)
const svalue * convert_svalue_from_summary(const svalue *)
hash_map< const svalue *, const svalue * > svalue_map_t
Definition call-summary.h:122
const call_details & get_call_details() const
Definition call-summary.h:75
region_model_manager * get_manager() const
Definition call-summary.h:77
const region * convert_region_from_summary(const region *)
std::unique_ptr< text_art::tree_widget > make_dump_widget(symbolic::node_dump_state &nds) const
region_model_context * get_ctxt() const
Definition call-summary.h:78
const extrinsic_state & m_ext_state
Definition call-summary.h:119
const region * convert_region_from_summary_1(const region *)
void dump_to_logger(logger &) const
const symbolic::scalar< ConcreteValueType > * impl_bits_from_bytes(const symbolic::scalar< ConcreteValueType > &summary_scalar)
const extrinsic_state & get_ext_state() const
Definition call-summary.h:81
const call_details & m_cd
Definition call-summary.h:117
region_map_t m_map_region_from_summary_to_caller
Definition call-summary.h:127
void add_svalue_mapping(const svalue *summary_sval, const svalue *caller_sval)
const symbolic::bit_contents * convert_bit_contents_from_summary(const symbolic::bit_contents &)
const gcall & get_call_stmt() const
Definition call-summary.h:76
const symbolic::scalar< ConcreteValueType > * convert_scalar_from_summary(const symbolic::scalar< ConcreteValueType > &)
hash_map< const region *, const region * > region_map_t
Definition call-summary.h:126
call_summary_replay(const call_details &cd, const function &called_fn, call_summary &summary, const extrinsic_state &ext_state)
const svalue * convert_svalue_from_summary_1(const svalue *)
call_summary & m_summary
Definition call-summary.h:118
svalue_map_t m_map_svalue_from_summary_to_caller
Definition call-summary.h:123
region_model * get_caller_model() const
Definition call-summary.h:79
DISABLE_COPY_AND_ASSIGN(call_summary_replay)
Definition call-summary.h:34
void dump_to_logger(logger &) const
tree get_fndecl() const
per_function_data *const m_per_fn_data
Definition call-summary.h:55
std::unique_ptr< text_art::tree_widget > make_dump_widget(symbolic::node_dump_state &nds) const
const program_state & get_state() const
call_summary(per_function_data *per_fn_data, const exploded_node *enode)
Definition call-summary.h:36
const exploded_node *const m_enode
Definition call-summary.h:56
void get_user_facing_desc(pretty_printer *pp) const
label_text get_desc() const
void dump() const
Definition exploded-graph.h:221
Definition program-state.h:34
Definition analyzer-logging.h:36
Definition program-state.h:239
Definition region-model.h:840
Definition region-model-manager.h:36
Definition region-model.h:289
Definition region.h:130
Definition svalue.h:82
Definition symbolic-bit-contents.h:68
Definition symbolic-bit-vectors.h:107
Definition symbolic-scalars.h:67
Definition ree.cc:583
Definition pretty-print.h:241
union tree_node * tree
Definition coretypes.h:97
Definition access-diagram.h:30
Definition exploded-graph.h:684
Definition symbolic-nodes.h:276
Definition function.h:249
Definition gimple.h:356