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 (goto_modelt &goto_model, const irep_idt &function_id, goto_functiont &goto_function, const exprt &top_level_write_set, const loop_contract_configt &loop_contract_config, 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 to use for the given instruction Returns the write set for the loop, or one of the outer loops, or top level, passing through all loops that are [must_skip]. 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 |
std::size_t | get_first_id_not_skipped_or_top_level_id (const std::size_t loop_id) const |
Returns the id of the first outer loop (including this one) that is not skipped, or the top level id. More... | |
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... | |
size_t | top_level_id () const |
Returns the top level ID. 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 242 of file dfcc_cfg_info.h.
dfcc_cfg_infot::dfcc_cfg_infot | ( | goto_modelt & | goto_model, |
const irep_idt & | function_id, | ||
goto_functiont & | goto_function, | ||
const exprt & | top_level_write_set, | ||
const loop_contract_configt & | loop_contract_config, | ||
symbol_table_baset & | symbol_table, | ||
message_handlert & | message_handler, | ||
dfcc_libraryt & | library | ||
) |
Definition at line 486 of file dfcc_cfg_info.cpp.
std::size_t dfcc_cfg_infot::get_first_id_not_skipped_or_top_level_id | ( | const std::size_t | loop_id | ) | const |
Returns the id of the first outer loop (including this one) that is not skipped, or the top level id.
Definition at line 650 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 698 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 725 of file dfcc_cfg_info.cpp.
|
inline |
Definition at line 279 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 732 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 715 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 312 of file dfcc_cfg_info.h.
|
inline |
Definition at line 305 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 680 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 to use for the given instruction Returns the write set for the loop, or one of the outer loops, or top level, passing through all loops that are [must_skip].
Definition at line 662 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 762 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 757 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 752 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 896 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 772 of file dfcc_cfg_info.cpp.
void dfcc_cfg_infot::output | ( | std::ostream & | out | ) | const |
Definition at line 606 of file dfcc_cfg_info.cpp.
|
private |
Returns the top level ID.
Definition at line 767 of file dfcc_cfg_info.cpp.
|
private |
Definition at line 318 of file dfcc_cfg_info.h.
|
private |
Definition at line 319 of file dfcc_cfg_info.h.
|
private |
Map from loop identifier to loop info struct.
Definition at line 350 of file dfcc_cfg_info.h.
|
private |
Definition at line 321 of file dfcc_cfg_info.h.
|
private |
Set of identifiers DECL at top level.
Definition at line 344 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 341 of file dfcc_cfg_info.h.
|
private |
Set of identifiers DECL at top level.
Definition at line 347 of file dfcc_cfg_info.h.
|
private |
Definition at line 320 of file dfcc_cfg_info.h.
|
private |
Loop identifiers sorted from most deeply nested to less deeply nested.
Definition at line 337 of file dfcc_cfg_info.h.