-
Notifications
You must be signed in to change notification settings - Fork 274
Clean_up related to symex_assign_symbol #4793
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 14 commits into
diffblue:develop
from
romainbrenguier:clean-up/symex-assign-symbol
Jun 17, 2019
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3d3bbdf
Inline variable used only once
romainbrenguier 389df45
Simplify assignment of l2_rhs
romainbrenguier 0c068ca
Declare variable closer to where it is used
romainbrenguier 2c5ef55
Inline variable that is immediately moved
romainbrenguier 98e7146
Remove misleading comment
romainbrenguier 360eb4a
Inline reference used only once
romainbrenguier a8af4d3
Infer hidden field in SSA_assignment_stept
romainbrenguier 093ee52
Infer cond_expr in SSA_assignment_step
romainbrenguier 56d7bba
Inline variables used immediatly after
romainbrenguier a97d61e
Clean-up increase_generation
romainbrenguier a577ed2
Add missing slash
romainbrenguier 7a8f8c7
Document l2_thread_write_encoding
romainbrenguier 3e9c60f
Formatting changes suggested by clang-format
romainbrenguier 71caf32
Make index in renamings be of std::size_t type
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
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 |
---|---|---|
|
@@ -29,7 +29,7 @@ Author: Romain Brenguier, [email protected] | |
/// This is extended by the different symex_level structures which are used | ||
/// during symex to ensure static single assignment (SSA) form. | ||
using symex_renaming_levelt = | ||
sharing_mapt<irep_idt, std::pair<ssa_exprt, unsigned>>; | ||
sharing_mapt<irep_idt, std::pair<ssa_exprt, std::size_t>>; | ||
|
||
/// Add the \c ssa_exprt of current_names to vars | ||
DEPRECATED(SINCE(2019, 6, 5, "Unused")) | ||
|
@@ -44,21 +44,21 @@ void get_variables( | |
/// a guard, a shared variable or a function. \p ns is queried to decide | ||
/// whether we are in one of these cases. | ||
renamedt<ssa_exprt, L0> | ||
symex_level0(ssa_exprt ssa_expr, const namespacet &ns, unsigned thread_nr); | ||
symex_level0(ssa_exprt ssa_expr, const namespacet &ns, std::size_t thread_nr); | ||
|
||
/// Functor to set the level 1 renaming of SSA expressions. | ||
/// Level 1 corresponds to function frames. | ||
/// This is to preserve locality in case of recursion | ||
struct symex_level1t | ||
{ | ||
/// Assume \p ssa is not already known | ||
void insert(const renamedt<ssa_exprt, L0> &ssa, unsigned index); | ||
void insert(const renamedt<ssa_exprt, L0> &ssa, std::size_t index); | ||
|
||
/// Set the index for \p ssa to index. | ||
/// \return if an index for \p ssa was already know, returns it's previous | ||
/// value. | ||
optionalt<std::pair<ssa_exprt, unsigned>> | ||
insert_or_replace(const renamedt<ssa_exprt, L0> &ssa, unsigned index); | ||
optionalt<std::pair<ssa_exprt, std::size_t>> | ||
insert_or_replace(const renamedt<ssa_exprt, L0> &ssa, std::size_t index); | ||
|
||
/// \return true if \p ssa has an associated index | ||
bool has(const renamedt<ssa_exprt, L0> &ssa) const; | ||
|
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 |
---|---|---|
|
@@ -395,8 +395,7 @@ void goto_symext::symex_assign_from_struct( | |
const exprt::operandst &guard, | ||
assignment_typet assignment_type) | ||
{ | ||
const struct_typet &type = to_struct_type(ns.follow(lhs.type())); | ||
const struct_union_typet::componentst &components = type.components(); | ||
const auto &components = to_struct_type(ns.follow(lhs.type())).components(); | ||
PRECONDITION(rhs.operands().size() == components.size()); | ||
|
||
for(std::size_t i = 0; i < components.size(); ++i) | ||
|
@@ -435,16 +434,15 @@ void goto_symext::symex_assign_symbol( | |
return; | ||
} | ||
|
||
exprt l2_rhs = [&]() { | ||
exprt guarded_rhs = rhs; | ||
// put assignment guard into the rhs | ||
if(!guard.empty()) | ||
{ | ||
guarded_rhs = | ||
if_exprt{conjunction(guard), std::move(guarded_rhs), lhs, rhs.type()}; | ||
} | ||
return state.rename(std::move(guarded_rhs), ns).get(); | ||
}(); | ||
exprt l2_rhs = | ||
state | ||
.rename( | ||
// put assignment guard into the rhs | ||
guard.empty() | ||
? rhs | ||
: static_cast<exprt>(if_exprt{conjunction(guard), rhs, lhs}), | ||
ns) | ||
.get(); | ||
|
||
// Note the following two calls are specifically required for | ||
// field-sensitivity. For example, with-expressions, which may have just been | ||
|
@@ -457,7 +455,6 @@ void goto_symext::symex_assign_symbol( | |
|
||
do_simplify(assignment.rhs); | ||
|
||
const ssa_exprt &l1_lhs = assignment.lhs; | ||
const ssa_exprt l2_lhs = state | ||
.assignment( | ||
assignment.lhs, | ||
|
@@ -468,15 +465,12 @@ void goto_symext::symex_assign_symbol( | |
symex_config.allow_pointer_unsoundness) | ||
.get(); | ||
|
||
exprt ssa_full_lhs = add_to_lhs(full_lhs, l2_lhs); | ||
state.record_events.push(false); | ||
const exprt l2_full_lhs = state.rename(std::move(ssa_full_lhs), ns).get(); | ||
const exprt l2_full_lhs = | ||
state.rename(add_to_lhs(full_lhs, l2_lhs), ns).get(); | ||
state.record_events.pop(); | ||
|
||
// do the assignment | ||
const symbolt &symbol = ns.lookup(l2_lhs.get_object_name()); | ||
|
||
if(symbol.is_auxiliary) | ||
if(ns.lookup(l2_lhs.get_object_name()).is_auxiliary) | ||
assignment_type=symex_targett::assignment_typet::HIDDEN; | ||
|
||
log.conditional_output( | ||
|
@@ -486,19 +480,16 @@ void goto_symext::symex_assign_symbol( | |
<< messaget::eom; | ||
}); | ||
|
||
const exprt assignment_guard = | ||
make_and(state.guard.as_expr(), conjunction(guard)); | ||
|
||
const exprt original_lhs = get_original_name(l2_full_lhs); | ||
target.assignment( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Random place: typo in the commit message: "this values" -> "these values", and also it should be "Inline variables" (plural) |
||
assignment_guard, | ||
make_and(state.guard.as_expr(), conjunction(guard)), | ||
l2_lhs, | ||
l2_full_lhs, | ||
original_lhs, | ||
get_original_name(l2_full_lhs), | ||
assignment.rhs, | ||
state.source, | ||
assignment_type); | ||
|
||
const ssa_exprt &l1_lhs = assignment.lhs; | ||
if(field_sensitivityt::is_divisible(l1_lhs)) | ||
{ | ||
// Split composite symbol lhs into its components | ||
|
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.
Note on the commit message: that's a "slash", not a "backslash"