Skip to content

Commit 6f692d7

Browse files
Merge pull request #4065 from peterschrammel/incremental-equation-conversion
Only convert not-yet-converted SSA steps
2 parents 00955b0 + fe72c88 commit 6f692d7

File tree

2 files changed

+45
-34
lines changed

2 files changed

+45
-34
lines changed

src/goto-symex/symex_target_equation.cpp

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,11 @@ void symex_target_equationt::convert(
351351
}
352352

353353
void symex_target_equationt::convert_assignments(
354-
decision_proceduret &decision_procedure) const
354+
decision_proceduret &decision_procedure)
355355
{
356-
for(const auto &step : SSA_steps)
356+
for(auto &step : SSA_steps)
357357
{
358-
if(step.is_assignment() && !step.ignore)
358+
if(step.is_assignment() && !step.ignore && !step.converted)
359359
{
360360
decision_procedure.conditional_output(
361361
decision_procedure.debug(),
@@ -365,22 +365,23 @@ void symex_target_equationt::convert_assignments(
365365
});
366366

367367
decision_procedure.set_to_true(step.cond_expr);
368+
step.converted = true;
368369
}
369370
}
370371
}
371372

372-
void symex_target_equationt::convert_decls(
373-
prop_convt &prop_conv) const
373+
void symex_target_equationt::convert_decls(prop_convt &prop_conv)
374374
{
375-
for(const auto &step : SSA_steps)
375+
for(auto &step : SSA_steps)
376376
{
377-
if(step.is_decl() && !step.ignore)
377+
if(step.is_decl() && !step.ignore && !step.converted)
378378
{
379379
// The result is not used, these have no impact on
380380
// the satisfiability of the formula.
381381
try
382382
{
383383
prop_conv.convert(step.cond_expr);
384+
step.converted = true;
384385
}
385386
catch(const bitvector_conversion_exceptiont &)
386387
{
@@ -489,31 +490,27 @@ void symex_target_equationt::convert_goto_instructions(
489490
}
490491

491492
void symex_target_equationt::convert_constraints(
492-
decision_proceduret &decision_procedure) const
493+
decision_proceduret &decision_procedure)
493494
{
494-
for(const auto &step : SSA_steps)
495+
for(auto &step : SSA_steps)
495496
{
496-
if(step.is_constraint())
497+
if(step.is_constraint() && !step.ignore && !step.converted)
497498
{
498-
if(!step.ignore)
499-
{
500-
decision_procedure.conditional_output(
501-
decision_procedure.debug(),
502-
[&step](messaget::mstreamt &mstream) {
503-
step.output(mstream);
504-
mstream << messaget::eom;
505-
});
499+
decision_procedure.conditional_output(
500+
decision_procedure.debug(), [&step](messaget::mstreamt &mstream) {
501+
step.output(mstream);
502+
mstream << messaget::eom;
503+
});
506504

507-
try
508-
{
509-
decision_procedure.set_to_true(step.cond_expr);
510-
}
511-
catch(const bitvector_conversion_exceptiont &)
512-
{
513-
util_throw_with_nested(
514-
equation_conversion_exceptiont(
515-
"Error converting constraints for step", step));
516-
}
505+
try
506+
{
507+
decision_procedure.set_to_true(step.cond_expr);
508+
step.converted = true;
509+
}
510+
catch(const bitvector_conversion_exceptiont &)
511+
{
512+
util_throw_with_nested(equation_conversion_exceptiont(
513+
"Error converting constraints for step", step));
517514
}
518515
}
519516
}
@@ -534,8 +531,13 @@ void symex_target_equationt::convert_assertions(
534531
{
535532
for(auto &step : SSA_steps)
536533
{
537-
if(step.is_assert())
534+
// ignore already converted assertions in the error trace
535+
if(step.is_assert() && step.converted)
536+
step.ignore = true;
537+
538+
if(step.is_assert() && !step.ignore && !step.converted)
538539
{
540+
step.converted = true;
539541
prop_conv.set_to_false(step.cond_expr);
540542
step.cond_literal=const_literal(false);
541543
return; // prevent further assumptions!
@@ -556,8 +558,14 @@ void symex_target_equationt::convert_assertions(
556558

557559
for(auto &step : SSA_steps)
558560
{
559-
if(step.is_assert())
561+
// ignore already converted assertions in the error trace
562+
if(step.is_assert() && step.converted)
563+
step.ignore = true;
564+
565+
if(step.is_assert() && !step.ignore && !step.converted)
560566
{
567+
step.converted = true;
568+
561569
prop_conv.conditional_output(
562570
prop_conv.debug(),
563571
[&step](messaget::mstreamt &mstream) {

src/goto-symex/symex_target_equation.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,12 @@ class symex_target_equationt:public symex_targett
171171
/// Converts assignments: set the equality _lhs==rhs_ to _True_.
172172
/// \param decision_procedure: A handle to a particular decision procedure
173173
/// interface
174-
void convert_assignments(decision_proceduret &decision_procedure) const;
174+
void convert_assignments(decision_proceduret &decision_procedure);
175175

176176
/// Converts declarations: these are effectively ignored by the decision
177177
/// procedure.
178178
/// \param prop_conv: A handle to a particular decision procedure interface
179-
void convert_decls(prop_convt &prop_conv) const;
179+
void convert_decls(prop_convt &prop_conv);
180180

181181
/// Converts assumptions: convert the expression the assumption represents.
182182
/// \param prop_conv: A handle to a particular decision procedure interface
@@ -189,7 +189,7 @@ class symex_target_equationt:public symex_targett
189189
/// Converts constraints: set the represented condition to _True_.
190190
/// \param decision_procedure: A handle to a particular decision procedure
191191
/// interface
192-
void convert_constraints(decision_proceduret &decision_procedure) const;
192+
void convert_constraints(decision_proceduret &decision_procedure);
193193

194194
/// Converts goto instructions: convert the expression representing the
195195
/// condition of this goto.
@@ -321,6 +321,9 @@ class symex_target_equationt:public symex_targett
321321
// for slicing
322322
bool ignore=false;
323323

324+
// for incremental conversion
325+
bool converted = false;
326+
324327
SSA_stept(const sourcet &_source, goto_trace_stept::typet _type)
325328
: source(_source),
326329
type(_type),
@@ -354,7 +357,7 @@ class symex_target_equationt:public symex_targett
354357
{
355358
return narrow_cast<std::size_t>(std::count_if(
356359
SSA_steps.begin(), SSA_steps.end(), [](const SSA_stept &step) {
357-
return step.is_assert();
360+
return step.is_assert() && !step.ignore && !step.converted;
358361
}));
359362
}
360363

0 commit comments

Comments
 (0)