Skip to content

Commit 81afb57

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 c83c1d2 commit 81afb57

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
@@ -622,33 +622,18 @@ void symex_target_equationt::convert_function_calls(
622622
{
623623
if(!step.ignore)
624624
{
625-
and_exprt::operandst conjuncts;
626625
step.converted_function_arguments.reserve(step.ssa_function_arguments.size());
627626

628627
for(const auto &arg : step.ssa_function_arguments)
629628
{
630-
if(arg.is_constant() ||
631-
arg.id()==ID_string_constant)
632-
step.converted_function_arguments.push_back(arg);
633-
else
629+
if(!arg.is_constant() && arg.id() != ID_string_constant)
634630
{
635-
const irep_idt identifier="symex::args::"+std::to_string(argument_count++);
636-
symbol_exprt symbol(identifier, arg.type());
637-
638-
equal_exprt eq(arg, symbol);
631+
equal_exprt eq{arg, arg};
639632
merge_irep(eq);
640-
641-
decision_procedure.set_to(eq, true);
642-
conjuncts.push_back(eq);
643-
step.converted_function_arguments.push_back(symbol);
633+
decision_procedure.set_to_true(eq);
644634
}
635+
step.converted_function_arguments.push_back(arg);
645636
}
646-
with_solver_hardness(
647-
decision_procedure,
648-
[step_index, &conjuncts, &step](solver_hardnesst &hardness) {
649-
hardness.register_ssa(
650-
step_index, conjunction(conjuncts), step.source.pc);
651-
});
652637
}
653638
++step_index;
654639
}
@@ -661,32 +646,16 @@ void symex_target_equationt::convert_io(decision_proceduret &decision_procedure)
661646
{
662647
if(!step.ignore)
663648
{
664-
and_exprt::operandst conjuncts;
665649
for(const auto &arg : step.io_args)
666650
{
667-
if(arg.is_constant() ||
668-
arg.id()==ID_string_constant)
669-
step.converted_io_args.push_back(arg);
670-
else
651+
if(!arg.is_constant() && arg.id() != ID_string_constant)
671652
{
672-
const irep_idt identifier =
673-
"symex::io::" + std::to_string(io_count++);
674-
symbol_exprt symbol(identifier, arg.type());
675-
676-
equal_exprt eq(arg, symbol);
653+
equal_exprt eq{arg, arg};
677654
merge_irep(eq);
678-
679-
decision_procedure.set_to(eq, true);
680-
conjuncts.push_back(eq);
681-
step.converted_io_args.push_back(symbol);
655+
decision_procedure.set_to_true(eq);
682656
}
657+
step.converted_io_args.push_back(arg);
683658
}
684-
with_solver_hardness(
685-
decision_procedure,
686-
[step_index, &conjuncts, &step](solver_hardnesst &hardness) {
687-
hardness.register_ssa(
688-
step_index, conjunction(conjuncts), step.source.pc);
689-
});
690659
}
691660
++step_index;
692661
}

0 commit comments

Comments
 (0)