-
Notifications
You must be signed in to change notification settings - Fork 278
Clean-up symex assignments #4735
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
romainbrenguier
merged 8 commits into
diffblue:develop
from
romainbrenguier:clean-up/symex-assign
Jun 3, 2019
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0399f89
Do not expose add_to_lhs in goto_symex interface
romainbrenguier efb8960
Remove unecessary type assignment
romainbrenguier 7deec89
Add missing const
romainbrenguier eb83306
Add an SSA_assignment_stept class with constructor
romainbrenguier 5119a01
Move make_and to expr_util
romainbrenguier 070cef9
Avoid modifying guard argument in symex assign
romainbrenguier 8391c17
Add missing const
romainbrenguier 63e01d9
make_and simplifies trivial expressions
romainbrenguier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ Author: Daniel Kroening, [email protected] | |
#include <util/c_types.h> | ||
#include <util/cprover_prefix.h> | ||
#include <util/exception_utils.h> | ||
#include <util/expr_util.h> | ||
#include <util/pointer_offset_size.h> | ||
#include <util/simplify_expr.h> | ||
|
||
|
@@ -79,9 +80,13 @@ void goto_symext::symex_assign(statet &state, const code_assignt &code) | |
} | ||
} | ||
|
||
exprt goto_symext::add_to_lhs( | ||
const exprt &lhs, | ||
const exprt &what) | ||
/// Store the \p what expression by recursively descending into the operands | ||
/// of \p lhs until the first operand \c op0 is _nil_: this _nil_ operand | ||
/// is then replaced with \p what. | ||
/// \param lhs: Non-symbol pointed-to expression | ||
/// \param what: The expression to be added to the \p lhs | ||
/// \return The resulting expression | ||
static exprt add_to_lhs(const exprt &lhs, const exprt &what) | ||
{ | ||
PRECONDITION(lhs.id() != ID_symbol); | ||
exprt tmp_what=what; | ||
|
@@ -387,7 +392,7 @@ void goto_symext::symex_assign_from_struct( | |
const ssa_exprt &lhs, // L1 | ||
const exprt &full_lhs, | ||
const struct_exprt &rhs, | ||
exprt::operandst &guard, | ||
const exprt::operandst &guard, | ||
assignment_typet assignment_type) | ||
{ | ||
const struct_typet &type = to_struct_type(ns.follow(lhs.type())); | ||
|
@@ -419,7 +424,7 @@ void goto_symext::symex_assign_symbol( | |
const ssa_exprt &lhs, // L1 | ||
const exprt &full_lhs, | ||
const exprt &rhs, | ||
exprt::operandst &guard, | ||
const exprt::operandst &guard, | ||
assignment_typet assignment_type) | ||
{ | ||
// Shortcut the common case of a whole-struct initializer: | ||
|
@@ -452,16 +457,16 @@ void goto_symext::symex_assign_symbol( | |
|
||
do_simplify(assignment.rhs); | ||
|
||
ssa_exprt &l1_lhs = assignment.lhs; | ||
ssa_exprt l2_lhs = state | ||
.assignment( | ||
assignment.lhs, | ||
assignment.rhs, | ||
ns, | ||
symex_config.simplify_opt, | ||
symex_config.constant_propagation, | ||
symex_config.allow_pointer_unsoundness) | ||
.get(); | ||
const ssa_exprt &l1_lhs = assignment.lhs; | ||
const ssa_exprt l2_lhs = state | ||
.assignment( | ||
assignment.lhs, | ||
assignment.rhs, | ||
ns, | ||
symex_config.simplify_opt, | ||
symex_config.constant_propagation, | ||
symex_config.allow_pointer_unsoundness) | ||
.get(); | ||
|
||
exprt ssa_full_lhs = add_to_lhs(full_lhs, l2_lhs); | ||
state.record_events.push(false); | ||
|
@@ -481,12 +486,12 @@ void goto_symext::symex_assign_symbol( | |
<< messaget::eom; | ||
}); | ||
|
||
// Temporarily add the state guard | ||
guard.emplace_back(state.guard.as_expr()); | ||
const exprt assignment_guard = | ||
make_and(state.guard.as_expr(), conjunction(guard)); | ||
|
||
const exprt original_lhs = get_original_name(l2_full_lhs); | ||
target.assignment( | ||
conjunction(guard), | ||
assignment_guard, | ||
l2_lhs, | ||
l2_full_lhs, | ||
original_lhs, | ||
|
@@ -505,9 +510,6 @@ void goto_symext::symex_assign_symbol( | |
state.propagation.erase_if_exists(l1_lhs.get_identifier()); | ||
state.value_set.erase_symbol(l1_lhs, ns); | ||
} | ||
|
||
// Restore the guard | ||
guard.pop_back(); | ||
} | ||
|
||
void goto_symext::symex_assign_typecast( | ||
|
@@ -564,10 +566,8 @@ void goto_symext::symex_assign_array( | |
// into | ||
// a'==a WITH [i:=e] | ||
|
||
with_exprt new_rhs(lhs_array, lhs_index, rhs); | ||
new_rhs.type() = lhs_index_type; | ||
|
||
exprt new_full_lhs=add_to_lhs(full_lhs, lhs); | ||
const with_exprt new_rhs{lhs_array, lhs_index, rhs}; | ||
const exprt new_full_lhs = add_to_lhs(full_lhs, lhs); | ||
|
||
symex_assign_rec( | ||
state, lhs_array, new_full_lhs, new_rhs, guard, assignment_type); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Presumably this was done this way in the name of performance. Have you checked that your change doesn't noticeably slow symex down?
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.
Before this was adding an exprt to a vector then using this vector to make the
and_exprt
of the conjunction, now we first make the conjunction and then add the exprt to the vector of theand_exprt
operands. So the operation are the same, just in a different order, this shouldn't impact performances.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.
@owen-jones-diffblue I just noticed that my change could lead to
assignment_guard
beingTRUE && TRUE
so I've added a commit to havemake_and
handle the constant cases, can you check that?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 seems good, once I saw from
exprt::is_true()
that boolean constantexprt
s must be eithertrue_exprt
orfalse_exprt
.