Skip to content

Commit 08d040f

Browse files
committed
Revert "Don't generate unnecessary fresh symbols for the GOTO trace"
This reverts commit c0f4c34.
1 parent 5d7080e commit 08d040f

File tree

4 files changed

+66
-27
lines changed

4 files changed

+66
-27
lines changed

regression/cbmc-incr-smt2/pointers-conversions/pointer_to_int.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
pointer_to_int.c
33
--trace
44
\[main\.assertion\.1\] line \d+ expected result == -1: success: SUCCESS

src/goto-symex/build_goto_trace.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,10 @@ void build_goto_trace(
351351
goto_trace_step.io_id = SSA_step.io_id;
352352
goto_trace_step.formatted = SSA_step.formatted;
353353
goto_trace_step.called_function = SSA_step.called_function;
354+
goto_trace_step.function_arguments = SSA_step.converted_function_arguments;
354355

355-
for(const auto &arg : SSA_step.converted_function_arguments)
356-
{
357-
goto_trace_step.function_arguments.push_back(
358-
simplify_expr(decision_procedure.get(arg), ns));
359-
}
356+
for(auto &arg : goto_trace_step.function_arguments)
357+
arg = decision_procedure.get(arg);
360358

361359
// update internal field for specific variables in the counterexample
362360
update_internal_field(SSA_step, goto_trace_step, ns);
@@ -393,8 +391,15 @@ void build_goto_trace(
393391

394392
for(const auto &j : SSA_step.converted_io_args)
395393
{
396-
goto_trace_step.io_args.push_back(
397-
simplify_expr(decision_procedure.get(j), ns));
394+
if(j.is_constant() || j.id() == ID_string_constant)
395+
{
396+
goto_trace_step.io_args.push_back(j);
397+
}
398+
else
399+
{
400+
exprt tmp = decision_procedure.get(j);
401+
goto_trace_step.io_args.push_back(tmp);
402+
}
398403
}
399404

400405
if(SSA_step.is_assert() || SSA_step.is_assume() || SSA_step.is_goto())

src/goto-symex/symex_target_equation.cpp

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -620,18 +620,33 @@ void symex_target_equationt::convert_function_calls(
620620
{
621621
if(!step.ignore)
622622
{
623+
and_exprt::operandst conjuncts;
623624
step.converted_function_arguments.reserve(step.ssa_function_arguments.size());
624625

625626
for(const auto &arg : step.ssa_function_arguments)
626627
{
627-
if(!arg.is_constant() && arg.id() != ID_string_constant)
628+
if(arg.is_constant() ||
629+
arg.id()==ID_string_constant)
630+
step.converted_function_arguments.push_back(arg);
631+
else
628632
{
629-
equal_exprt eq{arg, arg};
633+
const irep_idt identifier="symex::args::"+std::to_string(argument_count++);
634+
symbol_exprt symbol(identifier, arg.type());
635+
636+
equal_exprt eq(arg, symbol);
630637
merge_irep(eq);
631-
decision_procedure.set_to_true(eq);
638+
639+
decision_procedure.set_to(eq, true);
640+
conjuncts.push_back(eq);
641+
step.converted_function_arguments.push_back(symbol);
632642
}
633-
step.converted_function_arguments.push_back(arg);
634643
}
644+
with_solver_hardness(
645+
decision_procedure,
646+
[step_index, &conjuncts, &step](solver_hardnesst &hardness) {
647+
hardness.register_ssa(
648+
step_index, conjunction(conjuncts), step.source.pc);
649+
});
635650
}
636651
++step_index;
637652
}
@@ -644,16 +659,32 @@ void symex_target_equationt::convert_io(decision_proceduret &decision_procedure)
644659
{
645660
if(!step.ignore)
646661
{
662+
and_exprt::operandst conjuncts;
647663
for(const auto &arg : step.io_args)
648664
{
649-
if(!arg.is_constant() && arg.id() != ID_string_constant)
665+
if(arg.is_constant() ||
666+
arg.id()==ID_string_constant)
667+
step.converted_io_args.push_back(arg);
668+
else
650669
{
651-
equal_exprt eq{arg, arg};
670+
const irep_idt identifier =
671+
"symex::io::" + std::to_string(io_count++);
672+
symbol_exprt symbol(identifier, arg.type());
673+
674+
equal_exprt eq(arg, symbol);
652675
merge_irep(eq);
653-
decision_procedure.set_to_true(eq);
676+
677+
decision_procedure.set_to(eq, true);
678+
conjuncts.push_back(eq);
679+
step.converted_io_args.push_back(symbol);
654680
}
655-
step.converted_io_args.push_back(arg);
656681
}
682+
with_solver_hardness(
683+
decision_procedure,
684+
[step_index, &conjuncts, &step](solver_hardnesst &hardness) {
685+
hardness.register_ssa(
686+
step_index, conjunction(conjuncts), step.source.pc);
687+
});
657688
}
658689
++step_index;
659690
}

src/solvers/smt2/smt2_conv.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,14 @@ exprt smt2_convt::get(const exprt &expr) const
297297
if(it!=identifier_map.end())
298298
return it->second.value;
299299
}
300+
else if(expr.id()==ID_member)
301+
{
302+
const member_exprt &member_expr=to_member_expr(expr);
303+
exprt tmp=get(member_expr.struct_op());
304+
if(tmp.is_nil())
305+
return nil_exprt();
306+
return member_exprt(tmp, member_expr.get_component_name(), expr.type());
307+
}
300308
else if(expr.id() == ID_literal)
301309
{
302310
auto l = to_literal_expr(expr).get_literal();
@@ -315,17 +323,14 @@ exprt smt2_convt::get(const exprt &expr) const
315323
}
316324
else if(expr.is_constant())
317325
return expr;
318-
else if(expr.has_operands())
326+
else if(const auto &array = expr_try_dynamic_cast<array_exprt>(expr))
319327
{
320-
exprt copy = expr;
321-
for(auto &op : copy.operands())
328+
exprt array_copy = *array;
329+
for(auto &element : array_copy.operands())
322330
{
323-
exprt eval_op = get(op);
324-
if(eval_op.is_nil())
325-
return nil_exprt{};
326-
op = std::move(eval_op);
331+
element = get(element);
327332
}
328-
return copy;
333+
return array_copy;
329334
}
330335

331336
return nil_exprt();
@@ -4628,9 +4633,7 @@ void smt2_convt::set_to(const exprt &expr, bool value)
46284633
const irep_idt &identifier=
46294634
to_symbol_expr(equal_expr.lhs()).get_identifier();
46304635

4631-
if(
4632-
identifier_map.find(identifier) == identifier_map.end() &&
4633-
equal_expr.lhs() != equal_expr.rhs())
4636+
if(identifier_map.find(identifier)==identifier_map.end())
46344637
{
46354638
identifiert &id=identifier_map[identifier];
46364639
CHECK_RETURN(id.type.is_nil());

0 commit comments

Comments
 (0)