33 bool include_forward_reachability,
40 remove_calls_no_body(goto_functions, message_handler);
52 if(include_forward_reachability)
54 slice(goto_functions);
62 std::vector<reachability_slicert::cfgt::node_indext>
67 std::vector<cfgt::node_indext> sources;
71 criterion(
cfg[e_it.second].function_id, e_it.first) ||
72 is_threaded(e_it.first))
73 sources.push_back(e_it.second);
79 "no slicing criterion found",
81 "provide at least one property using --property <property>"};
95 return node1.function_id == node2.function_id && it1 == it2;
104 std::vector<reachability_slicert::cfgt::node_indext>
106 std::vector<cfgt::node_indext> stack)
108 std::vector<cfgt::node_indext> return_sites;
110 while(!stack.empty())
112 auto &node =
cfg[stack.back()];
115 if(node.reaches_assertion)
117 node.reaches_assertion =
true;
119 for(
const auto &edge : node.in)
121 const auto &pred_node =
cfg[edge.first];
123 if(pred_node.PC->is_end_function())
127 return_sites.push_back(edge.first);
130 std::prev(node.PC)->is_function_call(),
131 "all function return edges should point to the successor of a "
132 "FUNCTION_CALL instruction");
138 stack.push_back(edge.first);
156 std::vector<cfgt::node_indext> stack)
158 while(!stack.empty())
160 auto &node =
cfg[stack.back()];
163 if(node.reaches_assertion)
165 node.reaches_assertion =
true;
167 for(
const auto &edge : node.in)
169 const auto &pred_node =
cfg[edge.first];
171 if(pred_node.PC->is_end_function())
176 stack.push_back(edge.first);
179 std::prev(node.PC)->is_function_call(),
180 "all function return edges should point to the successor of a "
181 "FUNCTION_CALL instruction");
185 else if(pred_node.PC->is_function_call())
192 stack.push_back(edge.first);
208 std::vector<cfgt::node_indext> sources =
get_sources(is_threaded, criterion);
212 std::vector<cfgt::node_indext> return_sites =
228 const cfgt::nodet &call_node,
229 std::vector<cfgt::node_indext> &callsite_successor_stack,
230 std::vector<cfgt::node_indext> &callee_head_stack)
234 INVARIANT(call_node.out.size() == 1,
"Call sites should have one successor");
235 const auto successor_index = call_node.out.begin()->first;
237 auto callsite_successor_pc = std::next(call_node.PC);
239 auto successor_pc =
cfg[successor_index].PC;
243 callee_head_stack.push_back(successor_index);
246 while(!successor_pc->is_end_function())
250 callsite_successor_stack.push_back(
256 callsite_successor_stack.push_back(successor_index);
266 std::vector<reachability_slicert::cfgt::node_indext>
268 std::vector<cfgt::node_indext> stack)
270 std::vector<cfgt::node_indext> called_function_heads;
272 while(!stack.empty())
274 auto &node =
cfg[stack.back()];
277 if(node.reachable_from_assertion)
279 node.reachable_from_assertion =
true;
281 if(node.PC->is_function_call())
290 for(
const auto &edge : node.out)
291 stack.push_back(edge.first);
295 return called_function_heads;
306 std::vector<cfgt::node_indext> stack)
308 while(!stack.empty())
310 auto &node =
cfg[stack.back()];
313 if(node.reachable_from_assertion)
315 node.reachable_from_assertion =
true;
317 if(node.PC->is_function_call())
322 else if(node.PC->is_end_function())
331 for(
const auto &edge : node.out)
332 stack.push_back(edge.first);
347 std::vector<cfgt::node_indext> sources =
get_sources(is_threaded, criterion);
351 std::vector<cfgt::node_indext> return_sites =
367 if(gf_entry.second.body_available())
373 !e.reaches_assertion && !e.reachable_from_assertion &&
374 !i_it->is_end_function())
399 const bool include_forward_reachability,
406 include_forward_reachability,
420 const std::list<std::string> &properties,
421 const bool include_forward_reachability,
428 include_forward_reachability,
440 const std::list<std::string> &functions_list,
443 for(
const auto &
function : functions_list)
448 goto_model.
goto_functions, matching_criterion,
true, message_handler);
478 const std::list<std::string> &properties,
const entry_mapt & entries() const
Get a map from program points to their corresponding node indices.
entryt get_node_index(const goto_programt::const_targett &program_point) const
Get the graph node index for program_point.
nodet & get_node(const goto_programt::const_targett &program_point)
Get the CFG graph node relating to program_point.
const source_locationt & source_location() const
The Boolean constant false.
A collection of goto functions.
void compute_loop_numbers()
function_mapt function_map
goto_functionst goto_functions
GOTO functions.
static instructiont make_assumption(const exprt &g, const source_locationt &l=source_locationt::nil())
instructionst::const_iterator const_targett
Thrown when users pass incorrect command line arguments, for example passing no files to analysis or ...
std::vector< cfgt::node_indext > backward_outwards_walk_from(std::vector< cfgt::node_indext >)
Perform backward depth-first search of the control-flow graph of the goto program,...
bool is_same_target(goto_programt::const_targett it1, goto_programt::const_targett it2) const
std::vector< cfgt::node_indext > forward_outwards_walk_from(std::vector< cfgt::node_indext >)
Perform forwards depth-first search of the control-flow graph of the goto program,...
void backward_inwards_walk_from(std::vector< cfgt::node_indext >)
Perform backward depth-first search of the control-flow graph of the goto program,...
std::vector< cfgt::node_indext > get_sources(const is_threadedt &is_threaded, const slicing_criteriont &criterion)
Get the set of nodes that correspond to the given criterion, or that can appear in concurrent executi...
void operator()(goto_functionst &goto_functions, const slicing_criteriont &criterion, bool include_forward_reachability, message_handlert &)
void fixedpoint_to_assertions(const is_threadedt &is_threaded, const slicing_criteriont &criterion)
Perform backward depth-first search of the control-flow graph of the goto program,...
void fixedpoint_from_assertions(const is_threadedt &is_threaded, const slicing_criteriont &criterion)
Perform forwards depth-first search of the control-flow graph of the goto program,...
void forward_inwards_walk_from(std::vector< cfgt::node_indext >)
Perform forwards depth-first search of the control-flow graph of the goto program,...
void slice(goto_functionst &goto_functions)
This function removes all instructions that have the flag reaches_assertion or reachable_from_asserti...
void forward_walk_call_instruction(const cfgt::nodet &call_node, std::vector< cfgt::node_indext > &callsite_successor_stack, std::vector< cfgt::node_indext > &callee_head_stack)
Process a call instruction during a forwards reachability walk.
#define forall_goto_program_instructions(it, program)
#define Forall_goto_program_instructions(it, program)
Over-approximate Concurrency for Threaded Goto Programs.
void reachability_slicer(goto_modelt &goto_model, const bool include_forward_reachability, message_handlert &message_handler)
Perform reachability slicing on goto_model, with respect to the criterion given by all properties.
void function_path_reachability_slicer(goto_modelt &goto_model, const std::list< std::string > &functions_list, message_handlert &message_handler)
Perform reachability slicing on goto_model for selected functions.
Remove calls to functions without a body.
void remove_skip(goto_programt &goto_program, goto_programt::targett begin, goto_programt::targett end)
remove unnecessary skip statements
void remove_unreachable(goto_programt &goto_program)
remove unreachable code