-
Notifications
You must be signed in to change notification settings - Fork 277
merge_value_sets: Avoid assignment when actually values can be moved #4169
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
Conversation
src/goto-symex/goto_symex.h
Outdated
@@ -251,9 +251,9 @@ class goto_symext | |||
// gotos | |||
void merge_gotos(statet &); | |||
|
|||
virtual void merge_goto(const goto_statet &goto_state, statet &); | |||
virtual void merge_goto(goto_statet &goto_state, statet &); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what's happening here because there is no documentation. If the goto_state
is not supposed to be used afterwards then it would be good to make it clear, either by documenting or in the type, by forcing the argument to be movable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair, I'll work on adding documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation added.
src/goto-symex/symex_goto.cpp
Outdated
dest.value_set=src.value_set; | ||
// we don't actually need dest.value_set anymore, leave cleanup to later | ||
// cleanup of goto states | ||
dest.value_set.swap(src.value_set); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why swap and not move?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to take a look whether adding a move operator would be as easy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (just required also default-declaring a copy constructor).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫
This PR failed Diffblue compatibility checks (cbmc commit: d951590).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100661522
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: 8a23c84).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100662229
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formalise this with a move-ref and this lgtm
You may also be interested in @JohnDumbell is currently separating the concepts of fresh-l2-name (global) and current-l2-name (local), so that the L2 renaming map can be straightfowardly moved as well.
src/goto-checker/symex_bmc.h
Outdated
@@ -94,7 +94,7 @@ class symex_bmct : public goto_symext | |||
void symex_step(const get_goto_functiont &get_goto_function, statet &state) | |||
override; | |||
|
|||
void merge_goto(const goto_statet &goto_state, statet &state) override; | |||
void merge_goto(goto_statet &goto_state, statet &state) override; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If goto_state
is indeed dying then we should pass a goto_statet &&
I have incorporated all the feedback and have now triggered another profiling run just to make sure this is still working as expected. @kroening @peterschrammel either of you will need to review this as well. |
src/goto-symex/goto_symex.h
Outdated
@@ -232,12 +232,15 @@ class goto_symext | |||
|
|||
virtual void symex_assume(statet &, const exprt &cond); | |||
|
|||
// gotos | |||
/// Merge all branches joining at the current program point at the current | |||
/// program point. It will apply \ref merge_goto for each goto state (each of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The end of the first sentence is repeated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, thanks, fixed.
if(state.guard.is_false() && !goto_state.guard.is_false()) | ||
state.value_set = std::move(goto_state.value_set); | ||
else if(!goto_state.guard.is_false()) | ||
state.value_set.make_union(goto_state.value_set); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would also make sense for make_union
to not take a const ref, and use move instead. But that's maybe for another pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making this impactful is a bigger task, because the internal representation of a value set is reference counted. I'll leave this for another time.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫
This PR failed Diffblue compatibility checks (cbmc commit: 6c9937c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100793036
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: ad16b57).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100800932
@kroening and/or @peterschrammel would you mind taking a look at this one? It's just +25/−21 and is already coming up in other PRs (#4199). |
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 merge_goto.