-
Notifications
You must be signed in to change notification settings - Fork 274
Refactoring of symex_assign_symbol #4642
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
Refactoring of symex_assign_symbol #4642
Conversation
b4ba956
to
bf73aa7
Compare
src/goto-symex/goto_symex_state.cpp
Outdated
tmp, | ||
source, | ||
symex_targett::assignment_typet::PHI); | ||
|
||
expr = set_indices<L2>(std::move(ssa_l1), ns).get(); | ||
// TODO: are we setting l2 indices of something that is already l2? | ||
expr = set_indices<L2>(std::move(ssa_l2), ns).get(); |
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.
Could you try adding an assertion that this effectively returns ssa_l2
- I agree that this seems unnecessary, but maybe we're missing something.
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've now added an invariant before the call to check that ssa_l2 was correctly renamed.
@@ -452,8 +452,7 @@ bool goto_symex_statet::l2_thread_read_encoding( | |||
source, | |||
symex_targett::assignment_typet::PHI); | |||
|
|||
// TODO: are we setting l2 indices of something that is already l2? | |||
expr = set_indices<L2>(std::move(ssa_l2), ns).get(); | |||
expr = std::move(ssa_l2); |
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.
See my earlier comment: did you add an assertion to confirm this is doing what you expected across our regression tests?
The name better reflects what the variable represent and using move is clearer than swap.
guarded_rhs is only used to define l2_rhs, we make this explicit in the code.
This makes it a bit clearer what the shift_indexed_access_to_lhs function produced. It also avoids errors where the argument as a specific type but the identifier is overwritten, for instance: ``` symbol_exprt s1 = ...; shift_indexed_access_to_lhs(state, s1, lhs, ns, true); assert(s1 == ID_symbol); // may fail though s1 has type symbol_exprt ```
This avoids having an input that is also an output and makes what is modified by the call clearer. The argument was copied before the call anyway.
This avoids having parameters that are also output value, which is not clear from the calling site, and could cause some type mistakes when the exprt parameters is from a subtype of exprt.
This simplifies the call to this function and is clearer about the semantical relation between the lhs and rhs arguments.
This makes the relation between lhs and rhs clearer.
This avoids having an input that is also an output and clarifies how lhs is changed.
In practice there was an implicit stack of record events backup through the recursive calls, this makes the stack explicit.
The argument of add_to_lhs are const anyway.
It is not modified after assignment.
This avoids having an input that is also an output and make the calls to get_original_name clearer.
ssa_l2 is already an L2 expression, its indices doesn't need to be reset. We just check that the renaming was correct instead.
bf73aa7
to
fdc03e0
Compare
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: fdc03e0).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/111540186
@tautschnig I've added the check you suggested and everything works fine |
Having to debug some changes related to
symex_assign
I found it difficult to understand what variable represents what in the execution ofsymex_assign_symbol
because of several functions which have parameters that are also output. This pull request is an attempt to get rid of these.