CBMC
Loading...
Searching...
No Matches
dfcc_instrument_loop.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Dynamic frame condition checking for loop contracts
4
5Author: Qinheping Hu, qinhh@amazon.com
6
7Author: Remi Delmas, delmasrd@amazon.com
8
9Date: April 2023
10
11\*******************************************************************/
12
16
17#ifndef CPROVER_GOTO_INSTRUMENT_CONTRACTS_DYNAMIC_FRAMES_DFCC_INSTRUMENT_LOOP_H
18#define CPROVER_GOTO_INSTRUMENT_CONTRACTS_DYNAMIC_FRAMES_DFCC_INSTRUMENT_LOOP_H
19
20#include <util/message.h>
21
23
25
27class dfcc_libraryt;
31class dfcc_cfg_infot;
32
36{
37public:
48 message_handlert &message_handler,
52
113 // new_variant = loop_decreases;
132 void operator()(
133 const std::size_t loop_id,
134 const irep_idt &function_id,
135 goto_functiont &goto_function,
136 dfcc_cfg_infot &cfg_info,
137 const std::set<symbol_exprt> &local_statics,
138 std::set<irep_idt> &function_pointer_contracts);
139
141 std::size_t get_max_assigns_clause_size() const
142 {
144 }
145
146protected:
147 // keeps track of the maximum number of assigns clause targets
148 std::size_t max_assigns_clause_size = 0;
155
196 std::unordered_map<exprt, symbol_exprt, irep_hash> add_prehead_instructions(
197 const std::size_t loop_id,
198 goto_functionst::goto_functiont &goto_function,
199 symbol_table_baset &symbol_table,
203 exprt &invariant,
204 const exprt::operandst &assigns,
210 const irep_idt &symbol_mode);
211
245 const std::size_t loop_id,
246 const std::size_t cbmc_loop_id,
247 const irep_idt &function_id,
248 goto_functionst::goto_functiont &goto_function,
249 symbol_table_baset &symbol_table,
253 exprt &invariant,
254 const exprt::operandst &decreases_clauses,
256 const exprt &outer_write_set,
259 const std::vector<symbol_exprt> &old_decreases_vars);
260
293 const std::size_t loop_id,
294 const std::size_t cbmc_loop_id,
295 goto_functionst::goto_functiont &goto_function,
296 symbol_table_baset &symbol_table,
299 exprt &invariant,
300 const exprt::operandst &decreases_clauses,
303 const std::vector<symbol_exprt> &old_decreases_vars,
304 const std::vector<symbol_exprt> &new_decreases_vars,
306 const irep_idt &symbol_mode);
307
339 const std::size_t loop_id,
340 const std::size_t cbmc_loop_id,
341 goto_functionst::goto_functiont &goto_function,
345 const std::unordered_map<exprt, symbol_exprt, irep_hash> &history_var_map,
349 const std::vector<symbol_exprt> &old_decreases_vars,
350 const std::vector<symbol_exprt> &new_decreases_vars);
351};
352
353#endif
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
Computes natural loops, enforces normal form conditions, computes the nesting graph,...
Translates assigns and frees clauses of a function contract or loop contract into GOTO programs that ...
This class applies the loop contract transformation to a loop in a goto function.
void add_exit_instructions(const std::size_t loop_id, const std::size_t cbmc_loop_id, goto_functionst::goto_functiont &goto_function, goto_programt::targett loop_head, const symbol_exprt &loop_write_set, const symbol_exprt &addr_of_loop_write_set, const std::unordered_map< exprt, symbol_exprt, irep_hash > &history_var_map, const symbol_exprt &entered_loop, const symbol_exprt &initial_invariant, const symbol_exprt &in_base_case, const std::vector< symbol_exprt > &old_decreases_vars, const std::vector< symbol_exprt > &new_decreases_vars)
Adds instructions of the exit block.
dfcc_spec_functionst & spec_functions
void add_body_instructions(const std::size_t loop_id, const std::size_t cbmc_loop_id, goto_functionst::goto_functiont &goto_function, symbol_table_baset &symbol_table, goto_programt::targett loop_head, goto_programt::targett loop_latch, exprt &invariant, const exprt::operandst &decreases_clauses, const symbol_exprt &entered_loop, const symbol_exprt &in_base_case, const std::vector< symbol_exprt > &old_decreases_vars, const std::vector< symbol_exprt > &new_decreases_vars, const goto_programt::instructiont::targett &step_case_target, const irep_idt &symbol_mode)
Adds instructions of the body block.
std::unordered_map< exprt, symbol_exprt, irep_hash > add_prehead_instructions(const std::size_t loop_id, goto_functionst::goto_functiont &goto_function, symbol_table_baset &symbol_table, goto_programt::targett loop_head, goto_programt::targett loop_latch, goto_programt &assigns_instrs, exprt &invariant, const exprt::operandst &assigns, const symbol_exprt &loop_write_set, const symbol_exprt &addr_of_loop_write_set, const symbol_exprt &entered_loop, const symbol_exprt &initial_invariant, const symbol_exprt &in_base_case, const irep_idt &symbol_mode)
Adds instructions of prehead block, and return history variables.
std::size_t get_max_assigns_clause_size() const
Maximum number of assigns clause targets.
void operator()(const std::size_t loop_id, const irep_idt &function_id, goto_functiont &goto_function, dfcc_cfg_infot &cfg_info, const std::set< symbol_exprt > &local_statics, std::set< irep_idt > &function_pointer_contracts)
Replaces a loop by a base + step abstraction generated from its contract.
goto_programt::instructiont::targett add_step_instructions(const std::size_t loop_id, const std::size_t cbmc_loop_id, const irep_idt &function_id, goto_functionst::goto_functiont &goto_function, symbol_table_baset &symbol_table, goto_programt::targett loop_head, goto_programt::targett loop_latch, goto_programt &havoc_instrs, exprt &invariant, const exprt::operandst &decreases_clauses, const symbol_exprt &loop_write_set, const exprt &outer_write_set, const symbol_exprt &initial_invariant, const symbol_exprt &in_base_case, const std::vector< symbol_exprt > &old_decreases_vars)
Adds instructions of the step block, and returns the STEP jump target so that it can be used to jump ...
dfcc_contract_clauses_codegent & contract_clauses_codegen
This class instruments GOTO functions or instruction sequences for frame condition checking and loop ...
Class interface to library types and functions defined in cprover_contracts.c.
This class rewrites GOTO functions that use the built-ins:
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition dstring.h:38
Base class for all expressions.
Definition expr.h:56
std::vector< exprt > operandst
Definition expr.h:58
::goto_functiont goto_functiont
A goto function, consisting of function body (see body) and parameter identifiers (see parameter_iden...
std::list< instructiont >::iterator targett
The target for gotos and for start_thread nodes.
A generic container class for the GOTO intermediate representation of one function.
instructionst::iterator targett
Class that provides messages with a built-in verbosity 'level'.
Definition message.h:154
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition namespace.h:91
Expression to hold a symbol (variable)
Definition std_expr.h:131
The symbol table base class interface.
Symbol Table + CFG.
Field-insensitive, location-sensitive may-alias analysis.