Skip to content

Commit 8a23c84

Browse files
committed
merge_value_sets: Avoid assignment when actually values can be moved
We don't need the contents of the source anymore. Running on SV-COMP's ReachSafety-ECA, this saves 741s, which is approximately 9% of the runtime of goto_symext::merge_goto.
1 parent 3f0f776 commit 8a23c84

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

src/goto-checker/symex_bmc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void symex_bmct::symex_step(
8686
}
8787
}
8888

89-
void symex_bmct::merge_goto(const goto_statet &goto_state, statet &state)
89+
void symex_bmct::merge_goto(goto_statet &goto_state, statet &state)
9090
{
9191
const goto_programt::const_targett prev_pc = goto_state.source.pc;
9292
const guardt prev_guard = goto_state.guard;

src/goto-checker/symex_bmc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class symex_bmct : public goto_symext
9494
void symex_step(const get_goto_functiont &get_goto_function, statet &state)
9595
override;
9696

97-
void merge_goto(const goto_statet &goto_state, statet &state) override;
97+
void merge_goto(goto_statet &goto_state, statet &state) override;
9898

9999
bool should_stop_unwind(
100100
const symex_targett::sourcet &source,

src/goto-symex/goto_symex.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ class goto_symext
251251
// gotos
252252
void merge_gotos(statet &);
253253

254-
virtual void merge_goto(const goto_statet &goto_state, statet &);
254+
virtual void merge_goto(goto_statet &goto_state, statet &);
255255

256-
void merge_value_sets(const goto_statet &goto_state, statet &dest);
256+
void merge_value_sets(goto_statet &goto_state, statet &dest);
257257

258258
void phi_function(const goto_statet &goto_state, statet &);
259259

src/goto-symex/symex_goto.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ void goto_symext::merge_gotos(statet &state)
318318
frame.goto_state_map.erase(state_map_it);
319319
}
320320

321-
void goto_symext::merge_goto(const goto_statet &goto_state, statet &state)
321+
void goto_symext::merge_goto(goto_statet &goto_state, statet &state)
322322
{
323323
// check atomic section
324324
if(state.atomic_section_id != goto_state.atomic_section_id)
@@ -338,11 +338,13 @@ void goto_symext::merge_goto(const goto_statet &goto_state, statet &state)
338338
state.depth=std::min(state.depth, goto_state.depth);
339339
}
340340

341-
void goto_symext::merge_value_sets(const goto_statet &src, statet &dest)
341+
void goto_symext::merge_value_sets(goto_statet &src, statet &dest)
342342
{
343343
if(dest.guard.is_false())
344344
{
345-
dest.value_set=src.value_set;
345+
// we don't actually need dest.value_set anymore, leave cleanup to later
346+
// cleanup of goto states
347+
dest.value_set.swap(src.value_set);
346348
return;
347349
}
348350

src/pointer-analysis/value_set.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,11 @@ class value_sett
308308
values.clear();
309309
}
310310

311+
void swap(value_sett &other)
312+
{
313+
std::swap(values, other.values);
314+
}
315+
311316
/// Finds an entry in this value-set. The interface differs from get_entry
312317
/// because get_value_set_rec wants to check for a struct's first component
313318
/// before stripping the suffix as is done in get_entry.

0 commit comments

Comments
 (0)