ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
goto_loops.h
Go to the documentation of this file.
1#ifndef GOTO_PROGRAMS_GOTO_LOOPS_H_
2#define GOTO_PROGRAMS_GOTO_LOOPS_H_
3
7#include <unordered_map>
8
13bool check_var_name(const expr2tc &expr);
14
16{
17protected:
21
22 typedef std::list<loopst> function_loopst;
24
36 {
51 bool unnamed_write = false;
53 std::unordered_set<irep_idt, irep_id_hash> address_taken;
54
55 void record_write(const expr2tc &lhs);
56 void bind_arguments(
57 const goto_functiont &callee,
58 const std::vector<expr2tc> &arguments);
59 };
60 std::unordered_map<irep_idt, function_summaryt, irep_id_hash>
62
64 goto_programt::instructionst::iterator loop_head,
65 goto_programt::instructionst::iterator loop_exit);
66
68 goto_programt::instructionst::iterator instruction,
69 function_loopst::iterator loop,
70 std::vector<irep_idt> &function_name);
71
78 const irep_idt &fname,
79 std::vector<irep_idt> &in_progress,
81
82 static void
84
85 static void note_pointer_write(
86 const expr2tc &target,
87 function_summaryt &local,
88 std::vector<expr2tc> &written_ptrs);
89
92 bool summarise_call(
93 const code_function_call2t &call,
94 std::vector<irep_idt> &in_progress,
95 function_summaryt &local,
96 std::vector<expr2tc> &written_ptrs);
97
98 static void apply_callee_summary(
99 loopst &loop,
100 const function_summaryt &summary,
101 const code_function_call2t &call);
102
103 void collect_address_taken(const expr2tc &expr, function_summaryt &out) const;
104
106 void collect_loop_symbols(const expr2tc &expr, loopst::loop_varst &out) const;
107
113 void collect_lhs_symbols(const expr2tc &expr, function_summaryt &out) const;
114
115 void add_modified_var(loopst &loop, const expr2tc &expr);
116 void add_unmodified_var(loopst &loop, const expr2tc &expr);
117
118 void add_loop_var(loopst &loop, const expr2tc &expr, bool is_modified);
119
120public:
122 const irep_idt &_function_name,
123 goto_functionst &_goto_functions,
124 goto_functiont &_goto_function)
125 : function_name(_function_name),
126 goto_functions(_goto_functions),
127 goto_function(_goto_function)
128 {
130 }
131
132 void find_function_loops();
133 void dump() const;
134
136 {
137 return function_loops;
138 }
139
141 {
142 return function_loops;
143 }
144};
145
146#endif /* GOTO_PROGRAMS_GOTO_LOOPS_H_ */
Definition irep2_expr.h:2175
Definition goto_functions.h:56
Definition goto_functions.h:23
void add_unmodified_var(loopst &loop, const expr2tc &expr)
static void note_pointer_write(const expr2tc &target, function_summaryt &local, std::vector< expr2tc > &written_ptrs)
Definition goto_loops.cpp:394
bool summarise_call(const code_function_call2t &call, std::vector< irep_idt > &in_progress, function_summaryt &local, std::vector< expr2tc > &written_ptrs)
Fold a call inside a callee into that callee's summary.
Definition goto_loops.cpp:406
void collect_lhs_symbols(const expr2tc &expr, function_summaryt &out) const
Walk an assignment LHS, classifying each leaf symbol: storage that is actually written goes to modifi...
Definition goto_loops.cpp:331
static void merge_summary(const function_summaryt &from, function_summaryt &out)
Definition goto_loops.cpp:362
static void apply_callee_summary(loopst &loop, const function_summaryt &summary, const code_function_call2t &call)
Definition goto_loops.cpp:537
const function_loopst & get_loops() const
Definition goto_loops.h:135
void add_loop_var(loopst &loop, const expr2tc &expr, bool is_modified)
Definition goto_loops.cpp:625
void collect_address_taken(const expr2tc &expr, function_summaryt &out) const
A variable whose address the callee takes can be reassigned through that address, which collect_lhs_s...
Definition goto_loops.cpp:224
goto_functionst & goto_functions
Definition goto_loops.h:19
void create_function_loop(goto_programt::instructionst::iterator loop_head, goto_programt::instructionst::iterator loop_exit)
Definition goto_loops.cpp:126
void dump() const
Definition goto_loops.cpp:686
goto_loopst(const irep_idt &_function_name, goto_functionst &_goto_functions, goto_functiont &_goto_function)
Definition goto_loops.h:121
function_loopst & get_loops()
Definition goto_loops.h:140
goto_functiont & goto_function
Definition goto_loops.h:20
irep_idt function_name
Definition goto_loops.h:18
std::unordered_map< irep_idt, function_summaryt, irep_id_hash > function_summary_cache
Definition goto_loops.h:61
void find_function_loops()
Definition goto_loops.cpp:85
void collect_loop_symbols(const expr2tc &expr, loopst::loop_varst &out) const
Collect the leaf symbols of expr into out, applying check_var_name.
Definition goto_loops.cpp:314
void add_modified_var(loopst &loop, const expr2tc &expr)
function_loopst function_loops
Definition goto_loops.h:23
std::list< loopst > function_loopst
Definition goto_loops.h:22
void get_modified_variables(goto_programt::instructionst::iterator instruction, function_loopst::iterator loop, std::vector< irep_idt > &function_name)
Definition goto_loops.cpp:560
bool compute_function_summary(const irep_idt &fname, std::vector< irep_idt > &in_progress, function_summaryt &out)
Compute (or fetch the cached) summary of fname.
Definition goto_loops.cpp:451
Definition irep_idt.h:12
Definition loopst.h:8
std::unordered_set< expr2tc, irep2_hash > loop_varst
Definition loopst.h:14
bool check_var_name(const expr2tc &expr)
True for symbols that name genuine user storage — excludes ESBMC internals, return-value temporaries,...
Definition goto_loops.cpp:48
irep_container< expr2t > expr2tc
Definition irep2.h:431
Per-callee summary: the leaf symbols (post check_var_name filtering) that walking the callee's body w...
Definition goto_loops.h:36
bool writes_through_pointer
True iff the callee writes through a dereference.
Definition goto_loops.h:44
bool pointer_write_unresolvable
True iff the callee may write through a pointer it was not handed, so havocing the pointees of the ca...
Definition goto_loops.h:47
bool unnamed_write
Definition goto_loops.h:51
loopst::loop_varst modified
Definition goto_loops.h:37
void bind_arguments(const goto_functiont &callee, const std::vector< expr2tc > &arguments)
Restate the callee's written pointers in the caller's scope: a parameter the callee never reassigns h...
Definition goto_loops.cpp:282
void record_write(const expr2tc &lhs)
Definition goto_loops.cpp:244
loopst::loop_varst unmodified
Definition goto_loops.h:38
std::unordered_set< irep_idt, irep_id_hash > address_taken
The variables whose address the callee takes.
Definition goto_loops.h:53
bool modifies_pointer_array
True iff the callee writes an array element through a pointer, which havocking through the call's arg...
Definition goto_loops.h:41
loopst::loop_varst written_pointers
The pointers the callee writes through, in its own scope, and whether it writes through one it cannot...
Definition goto_loops.h:50