Skip to content

Commit c7f67c6

Browse files
committed
Don't generate unnecessary fresh symbols for the GOTO trace
We can safely record the values of expressions by adding `expr == expr` as constraints in order to be able to fetch and display them in the GOTO trace. This was already being done for declarations. Introducing new symbols just adds unnecessary variables to the formula. When running on various proofs done for AWS open-source projects, this changes the performance as follows: with CaDiCaL as back-end, the total solver time for the hardest 46 proofs changes from 26546.5 to 26779.7 seconds (233.2 seconds slow-down); with Minisat, however, the hardest 49 proofs take 28420.4 instead of 32387.2 seconds (3966.8 seconds speed-up). Across these benchmarks, 1.7% of variables and 0.6% of clauses are removed.
1 parent bf58af8 commit c7f67c6

File tree

2 files changed

+9
-40
lines changed

2 files changed

+9
-40
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-
CORE
1+
KNOWNBUG
22
pointer_to_int.c
33
--trace
44
\[main\.assertion\.1\] line \d+ expected result == -1: success: SUCCESS

src/goto-symex/symex_target_equation.cpp

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -624,33 +624,18 @@ void symex_target_equationt::convert_function_calls(
624624
{
625625
if(!step.ignore)
626626
{
627-
and_exprt::operandst conjuncts;
628627
step.converted_function_arguments.reserve(step.ssa_function_arguments.size());
629628

630629
for(const auto &arg : step.ssa_function_arguments)
631630
{
632-
if(arg.is_constant() ||
633-
arg.id()==ID_string_constant)
634-
step.converted_function_arguments.push_back(arg);
635-
else
631+
if(!arg.is_constant() && arg.id() != ID_string_constant)
636632
{
637-
const irep_idt identifier="symex::args::"+std::to_string(argument_count++);
638-
symbol_exprt symbol(identifier, arg.type());
639-
640-
equal_exprt eq(arg, symbol);
633+
equal_exprt eq{arg, arg};
641634
merge_irep(eq);
642-
643-
decision_procedure.set_to(eq, true);
644-
conjuncts.push_back(eq);
645-
step.converted_function_arguments.push_back(symbol);
635+
decision_procedure.set_to_true(eq);
646636
}
637+
step.converted_function_arguments.push_back(arg);
647638
}
648-
with_solver_hardness(
649-
decision_procedure,
650-
[step_index, &conjuncts, &step](solver_hardnesst &hardness) {
651-
hardness.register_ssa(
652-
step_index, conjunction(conjuncts), step.source.pc);
653-
});
654639
}
655640
++step_index;
656641
}
@@ -663,32 +648,16 @@ void symex_target_equationt::convert_io(decision_proceduret &decision_procedure)
663648
{
664649
if(!step.ignore)
665650
{
666-
and_exprt::operandst conjuncts;
667651
for(const auto &arg : step.io_args)
668652
{
669-
if(arg.is_constant() ||
670-
arg.id()==ID_string_constant)
671-
step.converted_io_args.push_back(arg);
672-
else
653+
if(!arg.is_constant() && arg.id() != ID_string_constant)
673654
{
674-
const irep_idt identifier =
675-
"symex::io::" + std::to_string(io_count++);
676-
symbol_exprt symbol(identifier, arg.type());
677-
678-
equal_exprt eq(arg, symbol);
655+
equal_exprt eq{arg, arg};
679656
merge_irep(eq);
680-
681-
decision_procedure.set_to(eq, true);
682-
conjuncts.push_back(eq);
683-
step.converted_io_args.push_back(symbol);
657+
decision_procedure.set_to_true(eq);
684658
}
659+
step.converted_io_args.push_back(arg);
685660
}
686-
with_solver_hardness(
687-
decision_procedure,
688-
[step_index, &conjuncts, &step](solver_hardnesst &hardness) {
689-
hardness.register_ssa(
690-
step_index, conjunction(conjuncts), step.source.pc);
691-
});
692661
}
693662
++step_index;
694663
}

0 commit comments

Comments
 (0)