-
Notifications
You must be signed in to change notification settings - Fork 277
Use the sharing map for the renaming level maps #4505
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,15 +226,15 @@ class goto_symex_statet final : public goto_statet | |
} | ||
|
||
/// Drops an L1 name from the local L2 map | ||
void drop_l1_name(symex_renaming_levelt::current_namest::const_iterator it) | ||
void drop_existing_l1_name(const irep_idt &l1_identifier) | ||
{ | ||
level2.current_names.erase(it); | ||
level2.current_names.erase(l1_identifier); | ||
} | ||
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. I think this method should either be removed or else be used from 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. The other version is now using |
||
|
||
/// Drops an L1 name from the local L2 map | ||
void drop_l1_name(const irep_idt &l1_identifier) | ||
{ | ||
level2.current_names.erase(l1_identifier); | ||
level2.current_names.erase_if_exists(l1_identifier); | ||
} | ||
|
||
std::function<std::size_t(const irep_idt &)> get_l2_name_provider() const | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,12 +55,15 @@ operator()(renamedt<ssa_exprt, L0> l0_expr) const | |
|
||
const irep_idt l0_name = l0_expr.get().get_l1_object_identifier(); | ||
|
||
const auto it = current_names.find(l0_name); | ||
if(it == current_names.end()) | ||
const auto r_opt = current_names.find(l0_name); | ||
|
||
if(!r_opt) | ||
{ | ||
return renamedt<ssa_exprt, L1>{std::move(l0_expr.value())}; | ||
} | ||
|
||
// rename! | ||
l0_expr.value().set_level_1(it->second.second); | ||
l0_expr.value().set_level_1(r_opt->get().second); | ||
return renamedt<ssa_exprt, L1>{std::move(l0_expr.value())}; | ||
} | ||
|
||
|
@@ -75,18 +78,21 @@ operator()(renamedt<ssa_exprt, L1> l1_expr) const | |
|
||
void symex_level1t::restore_from(const current_namest &other) | ||
{ | ||
auto it = current_names.begin(); | ||
for(const auto &pair : other) | ||
current_namest::delta_viewt delta_view; | ||
other.get_delta_view(current_names, delta_view, false); | ||
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.
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. Fixed |
||
|
||
for(const auto &delta_item : delta_view) | ||
{ | ||
while(it != current_names.end() && it->first < pair.first) | ||
++it; | ||
if(it == current_names.end() || pair.first < it->first) | ||
current_names.insert(it, pair); | ||
else if(it != current_names.end()) | ||
if(!delta_item.is_in_both_maps()) | ||
{ | ||
current_names.insert(delta_item.k, delta_item.m); | ||
} | ||
else | ||
{ | ||
PRECONDITION(it->first == pair.first); | ||
it->second = pair.second; | ||
++it; | ||
if(delta_item.m != delta_item.get_other_map_value()) | ||
{ | ||
current_names.replace(delta_item.k, delta_item.m); | ||
} | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ Author: Romain Brenguier, [email protected] | |
#include <unordered_set> | ||
|
||
#include <util/irep.h> | ||
#include <util/sharing_map.h> | ||
#include <util/simplify_expr.h> | ||
#include <util/ssa_expr.h> | ||
|
||
|
@@ -42,27 +43,26 @@ struct symex_renaming_levelt | |
symex_renaming_levelt(symex_renaming_levelt &&other) = default; | ||
|
||
/// Map identifier to ssa_exprt and counter | ||
typedef std::map<irep_idt, std::pair<ssa_exprt, unsigned>> current_namest; | ||
typedef sharing_mapt<irep_idt, std::pair<ssa_exprt, unsigned>> current_namest; | ||
current_namest current_names; | ||
|
||
/// Counter corresponding to an identifier | ||
unsigned current_count(const irep_idt &identifier) const | ||
{ | ||
const auto it = current_names.find(identifier); | ||
return it == current_names.end() ? 0 : it->second.second; | ||
} | ||
|
||
/// Increase the counter corresponding to an identifier | ||
static void increase_counter(const current_namest::iterator &it) | ||
{ | ||
++it->second.second; | ||
const auto r_opt = current_names.find(identifier); | ||
return !r_opt ? 0 : r_opt->get().second; | ||
} | ||
|
||
/// Add the \c ssa_exprt of current_names to vars | ||
void get_variables(std::unordered_set<ssa_exprt, irep_hash> &vars) const | ||
{ | ||
for(const auto &pair : current_names) | ||
current_namest::viewt view; | ||
current_names.get_view(view); | ||
|
||
for(const auto &pair : view) | ||
{ | ||
vars.insert(pair.second.first); | ||
} | ||
} | ||
}; | ||
|
||
|
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 I appreciate that this comment has been removed.
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.
Put back in