37 #ifndef CPROVER_ANALYSES_LEXICAL_LOOPS_H
38 #define CPROVER_ANALYSES_LEXICAL_LOOPS_H
63 template <
class P,
class T>
92 out <<
"Note not all loops were in lexical loop form\n";
114 template <
class P,
class T>
117 all_in_lexical_loop_form =
true;
120 for(
auto it = program.instructions.begin(); it != program.instructions.end();
123 if(it->is_backwards_goto())
125 const auto &target = it->get_target();
127 if(target->location_number <= it->location_number)
130 std::cout <<
"Computing loop for " << it->location_number <<
" -> "
131 << target->location_number <<
"\n";
134 if(!compute_lexical_loop(it, target))
135 all_in_lexical_loop_form =
false;
145 template <
class P,
class T>
151 loop_head->location_number <= loop_tail->location_number,
152 "loop header should come lexically before the tail");
155 std::set<T> loop_instructions;
157 loop_instructions.insert(loop_head);
158 loop_instructions.insert(loop_tail);
160 if(loop_head != loop_tail)
161 stack.push(loop_tail);
163 while(!stack.empty())
165 T loop_instruction = stack.top();
168 for(
auto predecessor : loop_instruction->incoming_edges)
171 predecessor->location_number > loop_tail->location_number ||
172 predecessor->location_number < loop_head->location_number)
177 if(loop_instructions.insert(predecessor).second)
178 stack.push(predecessor);
182 auto insert_result = parentt::loop_map.emplace(
188 return insert_result.second;
193 show_loops<lexical_loopst>(goto_model, out);
196 #endif // CPROVER_ANALYSES_LEXICAL_LOOPS_H