Skip to content
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

Cleanup wto: cpp+hpp, remove recursive version #699

Merged
merged 5 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions src/crab/fwd_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ class member_component_visitor final {
}
}

void operator()(std::shared_ptr<wto_cycle_t>& c) {
void operator()(const std::shared_ptr<wto_cycle_t>& c) {
if (!_found) {
_found = (c->head() == _node);
if (!_found) {
for (auto& component : *c) {
if (_found) {
break;
}
std::visit(*this, *component);
std::visit(*this, component);
}
}
}
Expand Down Expand Up @@ -114,7 +114,7 @@ class interleaved_fwd_fixpoint_iterator_t final {

void operator()(const label_t& node);

void operator()(std::shared_ptr<wto_cycle_t>& cycle);
void operator()(const std::shared_ptr<wto_cycle_t>& cycle);

friend std::pair<invariant_table_t, invariant_table_t> run_forward_analyzer(cfg_t& cfg, ebpf_domain_t entry_inv);
};
Expand All @@ -125,8 +125,8 @@ std::pair<invariant_table_t, invariant_table_t> run_forward_analyzer(cfg_t& cfg,
if (thread_local_options.check_termination) {
std::vector<label_t> cycle_heads;
for (auto& component : analyzer._wto) {
if (std::holds_alternative<std::shared_ptr<wto_cycle_t>>(*component)) {
cycle_heads.push_back(std::get<std::shared_ptr<wto_cycle_t>>(*component)->head());
if (std::holds_alternative<std::shared_ptr<wto_cycle_t>>(component)) {
cycle_heads.push_back(std::get<std::shared_ptr<wto_cycle_t>>(component)->head());
}
}
for (const label_t& label : cycle_heads) {
Expand All @@ -136,7 +136,7 @@ std::pair<invariant_table_t, invariant_table_t> run_forward_analyzer(cfg_t& cfg,
}
analyzer.set_pre(cfg.entry_label(), entry_inv);
for (auto& component : analyzer._wto) {
std::visit(analyzer, *component);
std::visit(analyzer, component);
}
return std::make_pair(analyzer._pre, analyzer._post);
}
Expand All @@ -156,7 +156,7 @@ void interleaved_fwd_fixpoint_iterator_t::operator()(const label_t& node) {
transform_to_post(node, pre);
}

void interleaved_fwd_fixpoint_iterator_t::operator()(std::shared_ptr<wto_cycle_t>& cycle) {
void interleaved_fwd_fixpoint_iterator_t::operator()(const std::shared_ptr<wto_cycle_t>& cycle) {
label_t head = cycle->head();

/** decide whether to skip cycle or not **/
Expand Down Expand Up @@ -190,9 +190,8 @@ void interleaved_fwd_fixpoint_iterator_t::operator()(std::shared_ptr<wto_cycle_t
set_pre(head, invariant);
transform_to_post(head, invariant);
for (auto& component : *cycle) {
wto_component_t c = *component;
if (!std::holds_alternative<label_t>(c) || (std::get<label_t>(c) != head)) {
std::visit(*this, *component);
if (!std::holds_alternative<label_t>(component) || (std::get<label_t>(component) != head)) {
std::visit(*this, component);
}
}
ebpf_domain_t new_pre = join_all_prevs(head);
Expand All @@ -211,9 +210,8 @@ void interleaved_fwd_fixpoint_iterator_t::operator()(std::shared_ptr<wto_cycle_t
transform_to_post(head, invariant);

for (auto& component : *cycle) {
wto_component_t c = *component;
if (!std::holds_alternative<label_t>(c) || (std::get<label_t>(c) != head)) {
std::visit(*this, *component);
if (!std::holds_alternative<label_t>(component) || (std::get<label_t>(component) != head)) {
std::visit(*this, component);
}
}
ebpf_domain_t new_pre = join_all_prevs(head);
Expand Down
4 changes: 2 additions & 2 deletions src/crab/thresholds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void wto_thresholds_t::operator()(const label_t& vertex) {
}
}

void wto_thresholds_t::operator()(std::shared_ptr<wto_cycle_t>& cycle) {
void wto_thresholds_t::operator()(const std::shared_ptr<wto_cycle_t>& cycle) {
thresholds_t thresholds(m_max_size);
auto& bb = m_cfg.get_node(cycle->head());
get_thresholds(bb, thresholds);
Expand All @@ -85,7 +85,7 @@ void wto_thresholds_t::operator()(std::shared_ptr<wto_cycle_t>& cycle) {
m_head_to_thresholds.insert(std::make_pair(cycle->head(), thresholds));
m_stack.push_back(cycle->head());
for (auto& component : *cycle) {
std::visit(*this, *component);
std::visit(*this, component);
}
m_stack.pop_back();
}
Expand Down
2 changes: 1 addition & 1 deletion src/crab/thresholds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class wto_thresholds_t final {

void operator()(const label_t& vertex);

void operator()(std::shared_ptr<wto_cycle_t>& cycle);
void operator()(const std::shared_ptr<wto_cycle_t>& cycle);

friend std::ostream& operator<<(std::ostream& o, const wto_thresholds_t& t);

Expand Down
Loading
Loading