Skip to content

Commit b0ec79a

Browse files
Use range in symex instead of merging sets of expressions
This part of the code is executed in all our tests so the fact that all existing tests pass should show this change works correctly. The performance difference for this change were evaluate on 143 methods from tika, which were chosen because analysis time was taking between 1 second and 1 minute for them. The time of symex step was evaluated alone (options --show-vcc --verbosity 0). The execution time for the whole of the benchmarks was reduced by 21% and the average speed up is 14% (the difference between the two means the optimization seems to have less influence on simpler benchmarks).
1 parent b6239d0 commit b0ec79a

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

src/goto-symex/symex_goto.cpp

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Author: Daniel Kroening, [email protected]
1616
#include <util/exception_utils.h>
1717
#include <util/invariant.h>
1818
#include <util/pointer_offset_size.h>
19+
#include <util/range.h>
1920
#include <util/std_expr.h>
2021

2122
#include <analyses/dirty.h>
@@ -357,26 +358,37 @@ void goto_symext::phi_function(
357358
const statet::goto_statet &goto_state,
358359
statet &dest_state)
359360
{
360-
// go over all variables to see what changed
361-
std::unordered_set<ssa_exprt, irep_hash> variables;
361+
auto ssa_of_current_name =
362+
[&](const std::pair<irep_idt, std::pair<ssa_exprt, unsigned>> &pair) {
363+
return pair.second.first;
364+
};
365+
366+
auto dest_state_names_range =
367+
make_range(dest_state.level2.current_names)
368+
.filter(
369+
[&](const std::pair<irep_idt, std::pair<ssa_exprt, unsigned>> &pair) {
370+
// We ignore the identifiers that are already in goto_state names
371+
return goto_state.level2_current_names.count(pair.first) == 0;
372+
})
373+
.map<const ssa_exprt>(ssa_of_current_name);
362374

363-
goto_state.level2_get_variables(variables);
364-
dest_state.level2.get_variables(variables);
375+
// go over all variables to see what changed
376+
auto all_current_names_range = make_range(goto_state.level2_current_names)
377+
.map<const ssa_exprt>(ssa_of_current_name)
378+
.concat(dest_state_names_range);
365379

366380
guardt diff_guard;
367-
368-
if(!variables.empty())
381+
if(!all_current_names_range.empty())
369382
{
370383
diff_guard=goto_state.guard;
371384

372385
// this gets the diff between the guards
373386
diff_guard-=dest_state.guard;
374387
}
375388

376-
for(std::unordered_set<ssa_exprt, irep_hash>::const_iterator
377-
it=variables.begin();
378-
it!=variables.end();
379-
it++)
389+
for(auto it = all_current_names_range.begin();
390+
it != all_current_names_range.end();
391+
++it)
380392
{
381393
const irep_idt l1_identifier=it->get_identifier();
382394
const irep_idt &obj_identifier=it->get_object_name();

0 commit comments

Comments
 (0)