void loop_transformt::transform(goto_programt &goto_program) { goto_program.compute_incoming_edges(); // pass 1: simple stuff Forall_goto_program_instructions(it, goto_program) if(it->is_backwards_goto()) { assert(it->targets.size()==1); goto_programt::targett begin = it->targets.front(); goto_programt::targett end = it; split_multi_head(goto_program, begin, end); transform_do_while(goto_program, begin, end); move_returns(goto_program, begin, end); } // pass 2: loop simulation Forall_goto_program_instructions(it, goto_program) if(it->is_backwards_goto()) { goto_programt::targett begin = it->targets.front(); goto_programt::targett end = it; std::set<goto_programt::targett> entries; std::set<goto_programt::targett> exits; analyze(goto_program, begin, end, entries, exits); transform(goto_program, begin, end, entries, exits); it=end; } goto_program.update(); #if 1 // Another run for debugging forall_goto_program_instructions(it, goto_program) if(it->is_backwards_goto()) { goto_programt::const_targett begin = it->targets.front(); goto_programt::const_targett end = it; run_checks(goto_program, begin, end); } #endif }
static int range_cmp(const void *l, const void *r) { run_checks(l, r); range_t *left = (range_t *)l, *right = (range_t *)r; return left->start - right->start; }