Skip to content

Commit 2b1d9f4

Browse files
Simplify single-path symex checker
Instead of handling the first symex run differently: Push initial state into the worklist, then iterate symex until done.
1 parent 0cf4c46 commit 2b1d9f4

File tree

3 files changed

+43
-89
lines changed

3 files changed

+43
-89
lines changed

src/goto-checker/single_path_symex_checker.cpp

Lines changed: 27 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -30,45 +30,6 @@ operator()(propertiest &properties)
3030
{
3131
resultt result(resultt::progresst::DONE);
3232

33-
// Unfortunately, the initial symex run is currently handled differently
34-
// from the subsequent runs
35-
if(!initial_symex_has_run)
36-
{
37-
initial_symex_has_run = true;
38-
first_equation = symex_target_equationt();
39-
symex_bmct symex(
40-
ui_message_handler,
41-
goto_model.get_symbol_table(),
42-
first_equation.value(),
43-
options,
44-
*worklist);
45-
46-
setup_symex(symex);
47-
perform_symex(
48-
goto_model,
49-
symex,
50-
symex_symbol_table,
51-
first_equation.value(),
52-
options,
53-
ns,
54-
ui_message_handler);
55-
56-
output_coverage_report(
57-
options.get_option("symex-coverage-report"),
58-
goto_model,
59-
symex,
60-
ui_message_handler);
61-
62-
if(symex.get_remaining_vccs() > 0)
63-
{
64-
prepare(result, properties, first_equation.value());
65-
decide(result, properties);
66-
67-
if(result.progress == resultt::progresst::FOUND_FAIL)
68-
return result;
69-
}
70-
}
71-
7233
// There might be more solutions from the previous equation.
7334
if(property_decider)
7435
{
@@ -77,24 +38,28 @@ operator()(propertiest &properties)
7738
return result;
7839
}
7940

80-
if(first_equation.has_value())
41+
if(!worklist->empty())
8142
{
82-
// We are in the second iteration. We don't need the equation
83-
// from the first iteration anymore.
84-
first_equation = {};
43+
// We pop the item processed in the previous iteration.
44+
worklist->pop();
8545
}
86-
else
46+
47+
if(!symex_initialized)
8748
{
88-
if(!worklist->empty())
89-
{
90-
// We are in iteration 3 or later; we pop the item processed
91-
// in the previous iteration.
92-
worklist->pop();
93-
}
94-
else
95-
{
96-
// We are already done.
97-
}
49+
symex_initialized = true;
50+
51+
// Put initial state into the work list
52+
symex_target_equationt equation;
53+
symex_bmct symex(
54+
ui_message_handler,
55+
goto_model.get_symbol_table(),
56+
equation,
57+
options,
58+
*worklist);
59+
setup_symex(symex);
60+
61+
symex.initialize_path_storage_from_entry_point_of(
62+
goto_symext::get_goto_function(goto_model), symex_symbol_table);
9863
}
9964

10065
while(!worklist->empty())
@@ -106,16 +71,15 @@ operator()(propertiest &properties)
10671
resume.equation,
10772
options,
10873
*worklist);
109-
11074
setup_symex(symex);
111-
perform_symex(
112-
goto_model,
113-
symex,
114-
resume,
115-
symex_symbol_table,
116-
options,
117-
ns,
118-
ui_message_handler);
75+
76+
symex.resume_symex_from_saved_state(
77+
goto_symext::get_goto_function(goto_model),
78+
resume.state,
79+
&resume.equation,
80+
symex_symbol_table);
81+
postprocess_equation(
82+
symex, resume.equation, options, ns, ui_message_handler);
11983

12084
output_coverage_report(
12185
options.get_option("symex-coverage-report"),

src/goto-checker/single_path_symex_checker.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ class single_path_symex_checkert : public single_path_symex_only_checkert,
4343
virtual ~single_path_symex_checkert() = default;
4444

4545
protected:
46-
bool initial_symex_has_run = false;
47-
optionalt<symex_target_equationt> first_equation; // for building traces
46+
bool symex_initialized = false;
4847
std::unique_ptr<goto_symex_property_decidert> property_decider;
4948

5049
void prepare(

src/goto-checker/single_path_symex_only_checker.cpp

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,19 @@ operator()(propertiest &properties)
3737
{
3838
resultt result(resultt::progresst::DONE);
3939

40-
// First run goto-symex from entry point to initialize worklist
4140
{
42-
symex_target_equationt first_equation;
41+
// Put initial state into the work list
42+
symex_target_equationt equation;
4343
symex_bmct symex(
4444
ui_message_handler,
4545
goto_model.get_symbol_table(),
46-
first_equation,
46+
equation,
4747
options,
4848
*worklist);
49-
5049
setup_symex(symex);
51-
perform_symex(
52-
goto_model,
53-
symex,
54-
symex_symbol_table,
55-
first_equation,
56-
options,
57-
ns,
58-
ui_message_handler);
5950

60-
equation_output(symex, first_equation);
61-
update_properties_status_from_symex_target_equation(
62-
properties, result.updated_properties, first_equation);
51+
symex.initialize_path_storage_from_entry_point_of(
52+
goto_symext::get_goto_function(goto_model), symex_symbol_table);
6353
}
6454

6555
while(!worklist->empty())
@@ -71,17 +61,18 @@ operator()(propertiest &properties)
7161
resume.equation,
7262
options,
7363
*worklist);
74-
7564
setup_symex(symex);
76-
perform_symex(
77-
goto_model,
78-
symex,
79-
resume,
80-
symex_symbol_table,
81-
options,
82-
ns,
83-
ui_message_handler);
65+
66+
symex.resume_symex_from_saved_state(
67+
goto_symext::get_goto_function(goto_model),
68+
resume.state,
69+
&resume.equation,
70+
symex_symbol_table);
71+
postprocess_equation(
72+
symex, resume.equation, options, ns, ui_message_handler);
73+
8474
equation_output(symex, resume.equation);
75+
8576
update_properties_status_from_symex_target_equation(
8677
properties, result.updated_properties, resume.equation);
8778

0 commit comments

Comments
 (0)