Skip to content

Commit 4a7a389

Browse files
authored
Merge pull request diffblue#2262 from karkhaz/kk-rm-noop-depth-lookup
Don't do string lookups in symex main loop
2 parents 6d5e446 + b5ebe6b commit 4a7a389

File tree

8 files changed

+36
-18
lines changed

8 files changed

+36
-18
lines changed

src/cbmc/bmc.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ void bmct::get_memory_model()
305305
void bmct::setup()
306306
{
307307
get_memory_model();
308-
symex.options=options;
309308

310309
{
311310
const symbolt *init_symbol;

src/cbmc/bmc.h

+12-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ class bmct:public safety_checkert
7676
ns(outer_symbol_table, symex_symbol_table),
7777
equation(),
7878
path_storage(_path_storage),
79-
symex(_message_handler, outer_symbol_table, equation, path_storage),
79+
symex(
80+
_message_handler,
81+
outer_symbol_table,
82+
equation,
83+
options,
84+
path_storage),
8085
prop_conv(_prop_conv),
8186
ui(ui_message_handlert::uit::PLAIN),
8287
driver_callback_after_symex(callback_after_symex)
@@ -150,7 +155,12 @@ class bmct:public safety_checkert
150155
ns(outer_symbol_table),
151156
equation(_equation),
152157
path_storage(_path_storage),
153-
symex(_message_handler, outer_symbol_table, equation, path_storage),
158+
symex(
159+
_message_handler,
160+
outer_symbol_table,
161+
equation,
162+
options,
163+
path_storage),
154164
prop_conv(_prop_conv),
155165
ui(ui_message_handlert::uit::PLAIN),
156166
driver_callback_after_symex(callback_after_symex)

src/cbmc/symex_bmc.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ symex_bmct::symex_bmct(
2222
message_handlert &mh,
2323
const symbol_tablet &outer_symbol_table,
2424
symex_target_equationt &_target,
25+
const optionst &options,
2526
path_storaget &path_storage)
26-
: goto_symext(mh, outer_symbol_table, _target, path_storage),
27+
: goto_symext(mh, outer_symbol_table, _target, options, path_storage),
2728
record_coverage(false),
2829
symex_coverage(ns)
2930
{

src/cbmc/symex_bmc.h

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class symex_bmct: public goto_symext
2929
message_handlert &mh,
3030
const symbol_tablet &outer_symbol_table,
3131
symex_target_equationt &_target,
32+
const optionst &options,
3233
path_storaget &path_storage);
3334

3435
// To show progress

src/goto-instrument/accelerate/scratch_program.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,16 @@ class scratch_programt:public goto_programt
4343
ns(symbol_table, symex_symbol_table),
4444
equation(),
4545
path_storage(),
46-
symex(mh, symbol_table, equation, path_storage),
46+
options(),
47+
symex(mh, symbol_table, equation, options, path_storage),
4748
satcheck(util_make_unique<satcheckt>()),
4849
satchecker(ns, *satcheck),
4950
z3(ns, "accelerate", "", "", smt2_dect::solvert::Z3),
5051
checker(&z3) // checker(&satchecker)
5152
{
53+
// Unconditionally set for performance reasons. This option setting applies
54+
// only to this program.
55+
options.set_option("simplify", true);
5256
}
5357

5458
void append(goto_programt::instructionst &instructions);
@@ -80,6 +84,7 @@ class scratch_programt:public goto_programt
8084
namespacet ns;
8185
symex_target_equationt equation;
8286
path_fifot path_storage;
87+
optionst options;
8388
goto_symext symex;
8489

8590
std::unique_ptr<propt> satcheck;

src/goto-symex/goto_symex.h

+9-4
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ class goto_symext
5252
message_handlert &mh,
5353
const symbol_tablet &outer_symbol_table,
5454
symex_target_equationt &_target,
55+
const optionst &options,
5556
path_storaget &path_storage)
5657
: should_pause_symex(false),
58+
options(options),
59+
max_depth(options.get_unsigned_int_option("depth")),
60+
doing_path_exploration(options.is_set("paths")),
5761
total_vccs(0),
5862
remaining_vccs(0),
5963
constant_propagation(true),
@@ -67,8 +71,6 @@ class goto_symext
6771
guard_identifier("goto_symex::\\guard"),
6872
path_storage(path_storage)
6973
{
70-
options.set_option("simplify", true);
71-
options.set_option("assertions", true);
7274
}
7375

7476
virtual ~goto_symext()
@@ -195,6 +197,11 @@ class goto_symext
195197
const get_goto_functiont &,
196198
statet &);
197199

200+
const optionst &options;
201+
202+
const unsigned max_depth;
203+
const bool doing_path_exploration;
204+
198205
public:
199206
// these bypass the target maps
200207
virtual void symex_step_goto(statet &, bool taken);
@@ -205,8 +212,6 @@ class goto_symext
205212
bool constant_propagation;
206213
bool self_loops_to_assumptions;
207214

208-
optionst options;
209-
210215
/// language_mode: ID_java, ID_C or another language identifier
211216
/// if we know the source language in use, irep_idt() otherwise.
212217
irep_idt language_mode;

src/goto-symex/symex_goto.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void goto_symext::symex_goto(statet &state)
114114
(simpl_state_guard.is_true() ||
115115
// or there is another block, but we're doing path exploration so
116116
// we're going to skip over it for now and return to it later.
117-
options.get_bool_option("paths")))
117+
doing_path_exploration))
118118
{
119119
DATA_INVARIANT(
120120
instruction.targets.size() > 0,
@@ -181,7 +181,7 @@ void goto_symext::symex_goto(statet &state)
181181
log.debug() << "Resuming from next instruction '"
182182
<< state_pc->source_location << "'" << log.eom;
183183
}
184-
else if(options.get_bool_option("paths"))
184+
else if(doing_path_exploration)
185185
{
186186
// We should save both the instruction after this goto, and the target of
187187
// the goto.

src/goto-symex/symex_main.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -308,16 +308,13 @@ void goto_symext::symex_step(
308308

309309
const goto_programt::instructiont &instruction=*state.source.pc;
310310

311-
if(!options.get_bool_option("paths"))
311+
if(!doing_path_exploration)
312312
merge_gotos(state);
313313

314314
// depth exceeded?
315-
{
316-
unsigned max_depth=options.get_unsigned_int_option("depth");
317-
if(max_depth!=0 && state.depth>max_depth)
318-
state.guard.add(false_exprt());
319-
state.depth++;
320-
}
315+
if(max_depth != 0 && state.depth > max_depth)
316+
state.guard.add(false_exprt());
317+
state.depth++;
321318

322319
// actually do instruction
323320
switch(instruction.type)

0 commit comments

Comments
 (0)