Skip to content

Don't do string lookups in symex main loop #2262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/cbmc/bmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ void bmct::get_memory_model()
void bmct::setup()
{
get_memory_model();
symex.options=options;

{
const symbolt *init_symbol;
Expand Down
14 changes: 12 additions & 2 deletions src/cbmc/bmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ class bmct:public safety_checkert
ns(outer_symbol_table, symex_symbol_table),
equation(),
path_storage(_path_storage),
symex(_message_handler, outer_symbol_table, equation, path_storage),
symex(
_message_handler,
outer_symbol_table,
equation,
options,
path_storage),
prop_conv(_prop_conv),
ui(ui_message_handlert::uit::PLAIN),
driver_callback_after_symex(callback_after_symex)
Expand Down Expand Up @@ -148,7 +153,12 @@ class bmct:public safety_checkert
ns(outer_symbol_table),
equation(_equation),
path_storage(_path_storage),
symex(_message_handler, outer_symbol_table, equation, path_storage),
symex(
_message_handler,
outer_symbol_table,
equation,
options,
path_storage),
prop_conv(_prop_conv),
ui(ui_message_handlert::uit::PLAIN),
driver_callback_after_symex(callback_after_symex)
Expand Down
3 changes: 2 additions & 1 deletion src/cbmc/symex_bmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ symex_bmct::symex_bmct(
message_handlert &mh,
const symbol_tablet &outer_symbol_table,
symex_target_equationt &_target,
const optionst &options,
path_storaget &path_storage)
: goto_symext(mh, outer_symbol_table, _target, path_storage),
: goto_symext(mh, outer_symbol_table, _target, options, path_storage),
record_coverage(false),
symex_coverage(ns)
{
Expand Down
1 change: 1 addition & 0 deletions src/cbmc/symex_bmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class symex_bmct: public goto_symext
message_handlert &mh,
const symbol_tablet &outer_symbol_table,
symex_target_equationt &_target,
const optionst &options,
path_storaget &path_storage);

// To show progress
Expand Down
7 changes: 6 additions & 1 deletion src/goto-instrument/accelerate/scratch_program.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ class scratch_programt:public goto_programt
ns(symbol_table, symex_symbol_table),
equation(),
path_storage(),
symex(mh, symbol_table, equation, path_storage),
options(),
symex(mh, symbol_table, equation, options, path_storage),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add

options.set_option("simplify", true);
options.set_option("assertions", true);

in the constructor body.

satcheck(util_make_unique<satcheckt>()),
satchecker(ns, *satcheck),
z3(ns, "accelerate", "", "", smt2_dect::solvert::Z3),
checker(&z3) // checker(&satchecker)
{
// Unconditionally set for performance reasons. This option setting applies
// only to this program.
options.set_option("simplify", true);
}

void append(goto_programt::instructionst &instructions);
Expand Down Expand Up @@ -80,6 +84,7 @@ class scratch_programt:public goto_programt
namespacet ns;
symex_target_equationt equation;
path_fifot path_storage;
optionst options;
goto_symext symex;

std::unique_ptr<propt> satcheck;
Expand Down
13 changes: 9 additions & 4 deletions src/goto-symex/goto_symex.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ class goto_symext
message_handlert &mh,
const symbol_tablet &outer_symbol_table,
symex_target_equationt &_target,
const optionst &options,
path_storaget &path_storage)
: should_pause_symex(false),
options(options),
max_depth(options.get_unsigned_int_option("depth")),
doing_path_exploration(options.is_set("paths")),
total_vccs(0),
remaining_vccs(0),
constant_propagation(true),
Expand All @@ -66,8 +70,6 @@ class goto_symext
guard_identifier("goto_symex::\\guard"),
path_storage(path_storage)
{
options.set_option("simplify", true);
options.set_option("assertions", true);
}

virtual ~goto_symext()
Expand Down Expand Up @@ -194,6 +196,11 @@ class goto_symext
const get_goto_functiont &,
statet &);

const optionst &options;

const unsigned max_depth;
const bool doing_path_exploration;

public:
// these bypass the target maps
virtual void symex_step_goto(statet &, bool taken);
Expand All @@ -203,8 +210,6 @@ class goto_symext

bool constant_propagation;

optionst options;

/// language_mode: ID_java, ID_C or another language identifier
/// if we know the source language in use, irep_idt() otherwise.
irep_idt language_mode;
Expand Down
4 changes: 2 additions & 2 deletions src/goto-symex/symex_goto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void goto_symext::symex_goto(statet &state)
(simpl_state_guard.is_true() ||
// or there is another block, but we're doing path exploration so
// we're going to skip over it for now and return to it later.
options.get_bool_option("paths")))
doing_path_exploration))
{
DATA_INVARIANT(
instruction.targets.size() > 0,
Expand Down Expand Up @@ -178,7 +178,7 @@ void goto_symext::symex_goto(statet &state)
log.debug() << "Resuming from next instruction '"
<< state_pc->source_location << "'" << log.eom;
}
else if(options.get_bool_option("paths"))
else if(doing_path_exploration)
{
// We should save both the instruction after this goto, and the target of
// the goto.
Expand Down
11 changes: 4 additions & 7 deletions src/goto-symex/symex_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,16 +308,13 @@ void goto_symext::symex_step(

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

if(!options.get_bool_option("paths"))
if(!doing_path_exploration)
merge_gotos(state);

// depth exceeded?
{
unsigned max_depth=options.get_unsigned_int_option("depth");
if(max_depth!=0 && state.depth>max_depth)
state.guard.add(false_exprt());
state.depth++;
}
if(max_depth != 0 && state.depth > max_depth)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(note for a future PR) This should be changed to use std::numeric_limits::max instead of 0.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

state.guard.add(false_exprt());
state.depth++;

// actually do instruction
switch(instruction.type)
Expand Down