17
17
18
18
#include < analyses/natural_loops.h>
19
19
#include < analyses/dependence_graph.h>
20
+ #include < analyses/goto_rw.h>
20
21
21
22
#include < goto-programs/remove_skip.h>
22
23
@@ -240,10 +241,16 @@ void abstract_loopst::abstract_goto_program(unsigned loop_num,
240
241
f_it = goto_functions.function_map .find (fn);
241
242
i_it = f_it->second .body .instructions .begin ();
242
243
std::advance (i_it, loop_info->init_loc - i_it->location_number );
243
- expr = i_it->code ;
244
- expr.id (is_inc ? ID_ge : ID_le);
245
- expr.type ().id (ID_bool);
246
- i_it->make_assumption (expr);
244
+
245
+ // init values can be nondet
246
+ const code_assignt &code_assign = to_code_assign (i_it->code );
247
+ if (!(code_assign.rhs ().id () == ID_side_effect))
248
+ {
249
+ expr = i_it->code ;
250
+ expr.id (is_inc ? ID_ge : ID_le);
251
+ expr.type ().id (ID_bool);
252
+ i_it->make_assumption (expr);
253
+ }
247
254
248
255
// change loop head into assumption, skip goto at loop end
249
256
loop_info->build_assumption ();
@@ -295,6 +302,7 @@ void abstract_loopst::check_assertion(unsigned location,
295
302
it != control_deps.end (); ++it)
296
303
{
297
304
add_to_queue (dep_set, dep_queue, (*it)->location_number );
305
+ ctrl_set.insert ((*it)->location_number );
298
306
}
299
307
}
300
308
@@ -311,7 +319,7 @@ void abstract_loopst::check_assertion(unsigned location,
311
319
add_to_queue (dep_set, dep_queue, (*it)->location_number );
312
320
// if(is_in_cycle(node, dep_graph))
313
321
// update_set.insert(node);
314
- if (ctrl_set.find (node) ! = ctrl_set.end ())
322
+ if (ctrl_set.find (node) = = ctrl_set.end ())
315
323
update_set.insert (node);
316
324
}
317
325
else
@@ -338,18 +346,7 @@ void abstract_loopst::check_assertion(unsigned location,
338
346
std::inserter (diff, diff.begin ()));
339
347
// loops containing the update nodes should not be shrinkable
340
348
for (auto loc: diff)
341
- {
342
- for (auto loop_n: insloop_map[loc])
343
- {
344
- irep_idt func = dep_graph[loc].PC ->function ;
345
- abstract_loopt *loop_info = &(absloop_map[func].find (loop_n)->second );
346
- loop_info->shrinkable = false ;
347
- #ifdef DEBUG_ABSTRACT_LOOPS
348
- std::cout << " - leaf node " << loc << " makes " << func << " ::"
349
- << loop_n << " unshrinkable\n " ;
350
- #endif
351
- }
352
- }
349
+ update_shrinkability (loc, dep_graph[loc].PC ->function );
353
350
354
351
// check dependence of update set
355
352
diff.clear ();
@@ -366,10 +363,17 @@ void abstract_loopst::check_assertion(unsigned location,
366
363
else
367
364
{
368
365
// check if the update depends on loop variable
366
+ const goto_programt::instructiont &inst = *(dep_graph[loc].PC );
367
+ std::cout << " check location " << loc << " type " << inst.type << " \n " ;
368
+ if (!inst.is_assign ())
369
+ continue ;
369
370
value_setst &value_sets=
370
371
dep_graph.reaching_definitions ().get_value_sets ();
371
372
rw_range_set_value_sett rw_set (ns, value_sets);
372
- goto_rw (dep_graph[loc].PC , rw_set);
373
+ rw_set.set_expr_r_set ();
374
+ const code_assignt &code_assign = to_code_assign (inst.code );
375
+ rw_set.get_objects_rec (dep_graph[loc].PC ,
376
+ rw_range_sett::get_modet::READ, code_assign.lhs ());
373
377
bool dep_on_loop_var = false ;
374
378
for (auto loop_n: insloop_map[loc])
375
379
{
@@ -499,16 +503,16 @@ void abstract_loopst::get_loop_info(
499
503
print_nodes (loop_info.var_updates );
500
504
#endif
501
505
502
- // This is for SVcomp cases where values can be nondet
503
- const code_assignt &code_assign =
504
- to_code_assign (dep_graph[loop_info.init_loc ].PC ->code );
505
- if (code_assign.rhs ().id () == ID_side_effect)
506
- {
507
- #ifdef DEBUG_ABSTRACT_LOOPS
508
- std::cout << " Unshrinkable: Loop variable init to nondet\n " ;
509
- #endif
510
- return ;
511
- }
506
+ // // This is for SVcomp cases where values can be nondet
507
+ // const code_assignt &code_assign =
508
+ // to_code_assign(dep_graph[loop_info.init_loc].PC->code);
509
+ // if(code_assign.rhs().id() == ID_side_effect)
510
+ // {
511
+ // #ifdef DEBUG_ABSTRACT_LOOPS
512
+ // std::cout << "Unshrinkable: Loop variable init to nondet\n";
513
+ // #endif
514
+ // return;
515
+ // }
512
516
513
517
// add to the instruction # -> loop # map
514
518
// unsafe with function call, further check when doing abstraction
0 commit comments