CBMC
|
Computes natural loops, enforces normal form conditions, computes the nesting graph, tags each instruction of the function with the loop ID of the innermost loop and loop instruction type. More...
#include <dfcc_cfg_info.h>
Public Member Functions | |
dfcc_cfg_infot (const irep_idt &function_id, goto_functiont &goto_function, const exprt &top_level_write_set, const dfcc_loop_contract_modet loop_contract_mode, symbol_table_baset &symbol_table, message_handlert &message_handler, dfcc_libraryt &library) | |
void | output (std::ostream &out) const |
const dfcc_loop_infot & | get_loop_info (const std::size_t loop_id) const |
Returns the loop info for that loop_id. More... | |
const exprt & | get_write_set (goto_programt::const_targett target) const |
Returns the write set variable for that instruction. More... | |
const std::unordered_set< irep_idt > & | get_local_set (goto_programt::const_targett target) const |
Returns the set of local variable for the scope where that target instruction is found. More... | |
const std::unordered_set< irep_idt > & | get_tracked_set (goto_programt::const_targett target) const |
Returns the subset of local variable that are explicitly tracked in the write set for the scope where that target instruction is found. More... | |
const exprt & | get_outer_write_set (std::size_t loop_id) const |
Returns the write set of the outer loop of that loop or the top level write set if that loop has no outer loop. More... | |
const std::vector< std::size_t > & | get_loops_toposorted () const |
const std::optional< std::size_t > | get_outer_loop_identifier (const std::size_t loop_id) const |
Finds the DFCC id of the loop that contains the given loop, returns nullopt when the loop has no outer loop. More... | |
bool | must_track_decl_or_dead (goto_programt::const_targett target) const |
True iff a DECL ident must be tracked in the write set of the loop that contains the DECL. More... | |
bool | must_check_lhs (goto_programt::const_targett target) const |
True iff the lhs of an assignment must be checked against the ambient write set. More... | |
const exprt & | get_top_level_write_set () const |
const std::unordered_set< irep_idt > & | get_top_level_tracked () |
Returns the set of top level symbols that must be tracked explicitly in the top level write set of the function. More... | |
Private Member Functions | |
bool | is_valid_loop_or_top_level_id (const std::size_t id) const |
True iff id is in the valid range for a loop id or is equal to the top level id for this function. More... | |
bool | is_valid_loop_id (const std::size_t id) const |
True iff id is in the valid range for a loop id for this function. More... | |
bool | is_top_level_id (const std::size_t id) const |
True iff id is in the valid range for a loop id for this function. More... | |
Private Attributes | |
const irep_idt & | function_id |
goto_functiont & | goto_function |
const exprt & | top_level_write_set |
const namespacet | ns |
std::vector< std::size_t > | topsorted_loops |
Loop identifiers sorted from most deeply nested to less deeply nested. More... | |
std::vector< std::size_t > | top_level_loops |
Loop identifiers for top level loops (ie for loops that are not nested in in another loop). More... | |
std::unordered_set< irep_idt > | top_level_local |
Set of identifiers DECL at top level. More... | |
std::unordered_set< irep_idt > | top_level_tracked |
Set of identifiers DECL at top level. More... | |
std::map< std::size_t, dfcc_loop_infot > | loop_info_map |
Map from loop identifier to loop info struct. More... | |
Computes natural loops, enforces normal form conditions, computes the nesting graph, tags each instruction of the function with the loop ID of the innermost loop and loop instruction type.
Loop identifiers range from 0 to nof_loops-1. Instructions that are not part of any loop are given nof_loop as id and the top-level instruction kind.
For example, the following function has three loops:
Natural loops are computed at the GOTO instruction level and a loop nesting graph is generated:
GOTO instructions are tagged as follows:
The tags allow to the dynamic frames instrumentation pass to select the write set instance of the specific loop to instrument the instruction, and allow the loop contracts instrumentation pass to robustly locate head, exiting nodes and latch nodes when applying the loop contract transformation.
Definition at line 234 of file dfcc_cfg_info.h.
dfcc_cfg_infot::dfcc_cfg_infot | ( | const irep_idt & | function_id, |
goto_functiont & | goto_function, | ||
const exprt & | top_level_write_set, | ||
const dfcc_loop_contract_modet | loop_contract_mode, | ||
symbol_table_baset & | symbol_table, | ||
message_handlert & | message_handler, | ||
dfcc_libraryt & | library | ||
) |
Definition at line 505 of file dfcc_cfg_info.cpp.
const std::unordered_set< irep_idt > & dfcc_cfg_infot::get_local_set | ( | goto_programt::const_targett | target | ) | const |
Returns the set of local variable for the scope where that target instruction is found.
Definition at line 680 of file dfcc_cfg_info.cpp.
const dfcc_loop_infot & dfcc_cfg_infot::get_loop_info | ( | const std::size_t | loop_id | ) | const |
Returns the loop info for that loop_id.
Definition at line 707 of file dfcc_cfg_info.cpp.
|
inline |
Definition at line 268 of file dfcc_cfg_info.h.
const std::optional< std::size_t > dfcc_cfg_infot::get_outer_loop_identifier | ( | const std::size_t | loop_id | ) | const |
Finds the DFCC id of the loop that contains the given loop, returns nullopt when the loop has no outer loop.
Definition at line 714 of file dfcc_cfg_info.cpp.
const exprt & dfcc_cfg_infot::get_outer_write_set | ( | std::size_t | loop_id | ) | const |
Returns the write set of the outer loop of that loop or the top level write set if that loop has no outer loop.
Definition at line 697 of file dfcc_cfg_info.cpp.
|
inline |
Returns the set of top level symbols that must be tracked explicitly in the top level write set of the function.
Definition at line 296 of file dfcc_cfg_info.h.
|
inline |
Definition at line 289 of file dfcc_cfg_info.h.
const std::unordered_set< irep_idt > & dfcc_cfg_infot::get_tracked_set | ( | goto_programt::const_targett | target | ) | const |
Returns the subset of local variable that are explicitly tracked in the write set for the scope where that target instruction is found.
Definition at line 662 of file dfcc_cfg_info.cpp.
const exprt & dfcc_cfg_infot::get_write_set | ( | goto_programt::const_targett | target | ) | const |
Returns the write set variable for that instruction.
Definition at line 644 of file dfcc_cfg_info.cpp.
|
private |
True iff id
is in the valid range for a loop id for this function.
Definition at line 744 of file dfcc_cfg_info.cpp.
|
private |
True iff id
is in the valid range for a loop id for this function.
Definition at line 739 of file dfcc_cfg_info.cpp.
|
private |
True iff id
is in the valid range for a loop id or is equal to the top level id for this function.
Definition at line 734 of file dfcc_cfg_info.cpp.
bool dfcc_cfg_infot::must_check_lhs | ( | goto_programt::const_targett | target | ) | const |
True iff the lhs
of an assignment must be checked against the ambient write set.
We say a lhs must be checked if
Definition at line 874 of file dfcc_cfg_info.cpp.
bool dfcc_cfg_infot::must_track_decl_or_dead | ( | goto_programt::const_targett | target | ) | const |
True iff a DECL ident must be tracked in the write set of the loop that contains the DECL.
Definition at line 749 of file dfcc_cfg_info.cpp.
void dfcc_cfg_infot::output | ( | std::ostream & | out | ) | const |
Definition at line 599 of file dfcc_cfg_info.cpp.
|
private |
Definition at line 302 of file dfcc_cfg_info.h.
|
private |
Definition at line 303 of file dfcc_cfg_info.h.
|
private |
Map from loop identifier to loop info struct.
Definition at line 331 of file dfcc_cfg_info.h.
|
private |
Definition at line 305 of file dfcc_cfg_info.h.
|
private |
Set of identifiers DECL at top level.
Definition at line 325 of file dfcc_cfg_info.h.
|
private |
Loop identifiers for top level loops (ie for loops that are not nested in in another loop).
Definition at line 322 of file dfcc_cfg_info.h.
|
private |
Set of identifiers DECL at top level.
Definition at line 328 of file dfcc_cfg_info.h.
|
private |
Definition at line 304 of file dfcc_cfg_info.h.
|
private |
Loop identifiers sorted from most deeply nested to less deeply nested.
Definition at line 318 of file dfcc_cfg_info.h.