12 #ifndef CPROVER_ANALYSES_NATURAL_LOOPS_H 13 #define CPROVER_ANALYSES_NATURAL_LOOPS_H 24 template<
class P,
class T>
40 void output(std::ostream &)
const;
66 goto_programt::const_targett>
80 template<
class P,
class T>
90 for(T m_it=program.instructions.begin();
91 m_it!=program.instructions.end();
94 if(m_it->is_backwards_goto())
96 for(
const auto &target : m_it->targets)
98 if(target->location_number<=m_it->location_number)
104 std::cout <<
"Computing loop for " 105 << m_it->location_number <<
" -> " 106 << target->location_number <<
"\n";
108 if(node.dominators.find(target)!=node.dominators.end())
119 template<
class P,
class T>
122 assert(n->location_number<=m->location_number);
134 while(!stack.empty())
142 for(
const auto &edge : node.in)
145 std::pair<typename natural_loopt::const_iterator, bool> result=
154 template<
class P,
class T>
159 unsigned n=loop.first->location_number;
161 out << n <<
" is head of { ";
162 for(
typename natural_loopt::const_iterator l_it=loop.second.begin();
163 l_it!=loop.second.end(); ++l_it)
165 if(l_it!=loop.second.begin())
167 out << (*l_it)->location_number;
173 #endif // CPROVER_ANALYSES_NATURAL_LOOPS_H void output(std::ostream &) const
Print all natural loops that were found.
const cfg_dominators_templatet< P, T, false > & get_dominator_info() const
cfg_dominators_templatet< P, T, false >::cfgt::nodet nodet
Goto Programs with Functions.
std::set< T > natural_loopt
natural_loops_templatet< goto_programt, goto_programt::targett > natural_loops_mutablet
std::map< T, natural_loopt > loop_mapt
cfg_dominators_templatet< P, T, false > cfg_dominators
void show_natural_loops(const goto_functionst &goto_functions)
void output(std::ostream &) const
Print the result of the dominator computation.
void compute_natural_loop(T, T)
Computes the natural loop for a given back-edge (see Muchnick section 7.4)
natural_loops_templatet(P &program)
natural_loops_templatet()
Compute dominators for CFG of goto_function.
void compute(P &program)
Finds all back-edges and computes the natural loops.
void operator()(P &program)