17 #ifdef DEBUG_FULL_SLICERT 23 const cfgt::nodet &node,
29 dep_graph[dep_graph[node.PC].get_node_id()];
31 for(dependence_grapht::edgest::const_iterator
35 add_to_queue(queue, dep_node_to_cfg[it->first], node.PC);
39 const cfgt::nodet &node,
43 goto_functionst::function_mapt::const_iterator f_it=
47 assert(!f_it->second.body.instructions.empty());
49 f_it->second.body.instructions.begin();
51 cfgt::entry_mapt::const_iterator entry=
55 for(cfgt::edgest::const_iterator
56 it=
cfg[entry->second].
in.begin();
57 it!=
cfg[entry->second].
in.end();
63 const cfgt::nodet &node,
74 for(find_symbols_sett::const_iterator
79 decl_deadt::iterator entry=decl_dead.find(*it);
80 if(entry==decl_dead.end())
83 while(!entry->second.empty())
89 decl_dead.erase(entry);
123 jumpst::iterator next=it;
138 for( ; !lex_succ->is_end_function(); ++lex_succ)
140 cfgt::entry_mapt::const_iterator entry=
144 if(
cfg[entry->second].node_required)
147 if(lex_succ->is_end_function())
156 cfg_post_dominatorst::cfgt::entry_mapt::const_iterator e=
165 if(n.dominators.find(lex_succ)==n.dominators.end())
175 std::size_t post_dom_size=0;
176 for(cfg_dominatorst::target_sett::const_iterator
177 d_it=n.dominators.begin();
178 d_it!=n.dominators.end();
181 cfgt::entry_mapt::const_iterator entry=
185 if(
cfg[entry->second].node_required)
190 cfg_post_dominatorst::cfgt::entry_mapt::const_iterator e2=
198 if(n2.dominators.size()>post_dom_size)
201 post_dom_size=n2.dominators.
size();
205 if(nearest!=lex_succ)
223 std::vector<cfgt::entryt> dep_node_to_cfg;
224 dep_node_to_cfg.reserve(dep_graph.
size());
227 cfgt::entry_mapt::const_iterator entry=
231 dep_node_to_cfg.push_back(entry->second);
235 while(!queue.empty())
237 while(!queue.empty())
244 if(node.node_required)
248 node.node_required=
true;
269 const irep_idt &statement=target->code.get_statement();
270 if(statement==ID_array_copy)
273 if(!target->is_assign())
277 if(a.
lhs().
id()!=ID_symbol)
300 for(cfgt::entry_mapt::iterator
305 if(criterion(e_it->first))
309 else if((e_it->first->is_goto() && e_it->first->guard.is_true()) ||
310 e_it->first->is_throw())
311 jumps.push_back(e_it->second);
312 else if(e_it->first->is_decl())
317 else if(e_it->first->is_dead())
326 dep_graph(goto_functions, ns);
329 fixedpoint(goto_functions, queue, jumps, decl_dead, dep_graph);
335 if(f_it->second.body_available())
340 if(!i_it->is_end_function() &&
341 !
cfg[e].node_required)
343 #ifdef DEBUG_FULL_SLICERT 346 std::string c=
"ins:"+std::to_string(i_it->location_number);
348 for(std::set<unsigned>::const_iterator
349 req_it=
cfg[e].required_by.begin();
350 req_it!=
cfg[e].required_by.end();
353 if(req_it!=
cfg[e].required_by.begin())
355 c+=std::to_string(*req_it);
357 i_it->source_location.set_column(c);
358 i_it->source_location.set_comment(c);
388 const std::list<std::string> &properties)
const code_declt & to_code_decl(const codet &code)
void add_dependencies(const cfgt::nodet &node, queuet &queue, const dependence_grapht &dep_graph, const dep_node_to_cfgt &dep_node_to_cfg)
const code_deadt & to_code_dead(const codet &code)
virtual ~slicing_criteriont()
const irep_idt & get_identifier() const
static const irep_idt get_function_id(const_targett l)
static bool implicit(goto_programt::const_targett target)
std::unordered_set< irep_idt, irep_id_hash > find_symbols_sett
const code_assignt & to_code_assign(const codet &code)
const irep_idt & id() const
instructionst::const_iterator const_targett
std::stack< cfgt::entryt > queuet
cfg_base_nodet< cfg_nodet, goto_programt::const_targett > nodet
std::map< irep_idt, cfg_post_dominatorst > post_dominators_mapt
void fixedpoint(goto_functionst &goto_functions, queuet &queue, jumpst &jumps, decl_deadt &decl_dead, const dependence_grapht &dep_graph)
std::list< cfgt::entryt > jumpst
const post_dominators_mapt & cfg_post_dominators() const
void full_slicer(goto_functionst &goto_functions, const namespacet &ns, slicing_criteriont &criterion)
void add_decl_dead(const cfgt::nodet &node, queuet &queue, decl_deadt &decl_dead)
nodet::node_indext node_indext
void property_slicer(goto_functionst &goto_functions, const namespacet &ns, const std::list< std::string > &properties)
void add_function_calls(const cfgt::nodet &node, queuet &queue, const goto_functionst &goto_functions)
function_mapt function_map
std::unordered_map< irep_idt, queuet, irep_id_hash > decl_deadt
void add_to_queue(queuet &queue, const cfgt::entryt &entry, goto_programt::const_targett reason)
void remove_skip(goto_programt &goto_program)
remove unnecessary skip statements
Base class for all expressions.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast a generic exprt to a symbol_exprt.
#define Forall_goto_functions(it, functions)
const edgest & in(node_indext n) const
#define Forall_goto_program_instructions(it, program)
Expression to hold a symbol (variable)
void operator()(goto_functionst &goto_functions, const namespacet &ns, slicing_criteriont &criterion)
void add_jumps(queuet &queue, jumpst &jumps, const dependence_grapht::post_dominators_mapt &post_dominators)
std::vector< cfgt::entryt > dep_node_to_cfgt
void find_symbols(const exprt &src, find_symbols_sett &dest)