Skip to content

Commit

Permalink
Revert "Add edge type parameter to ai transform method"
Browse files Browse the repository at this point in the history
This reverts commit f8e38fb.

There are a number of problems with commit
f8e38fb :
1. This is a key API and breaks out-of-tree abstract domains.
2. It doesn't take into account the invariants on transform.
3. The extra parameter duplicates information in the arguments
   and confuses cases; without a body a CALL instruction is not a CALL.
4. It doesn't fix all of the issues in tranform functions.
5. It doesn't fix the corresponding API issues with merge.
  • Loading branch information
martin committed Feb 9, 2018
1 parent 3ca91bc commit 1990994
Show file tree
Hide file tree
Showing 22 changed files with 25 additions and 61 deletions.
12 changes: 4 additions & 8 deletions src/analyses/ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,7 @@ bool ai_baset::visit(
// initialize state, if necessary
get_state(to_l);

new_values.transform(
l, to_l, *this, ns, ai_domain_baset::edge_typet::FUNCTION_LOCAL);
new_values.transform(l, to_l, *this, ns);

if(merge(new_values, l, to_l))
have_new_values=true;
Expand Down Expand Up @@ -399,8 +398,7 @@ bool ai_baset::do_function_call(
{
// if we don't have a body, we just do an edige call -> return
std::unique_ptr<statet> tmp_state(make_temporary_state(get_state(l_call)));
tmp_state->transform(
l_call, l_return, *this, ns, ai_domain_baset::edge_typet::FUNCTION_LOCAL);
tmp_state->transform(l_call, l_return, *this, ns);

return merge(*tmp_state, l_call, l_return);
}
Expand All @@ -417,8 +415,7 @@ bool ai_baset::do_function_call(

// do the edge from the call site to the beginning of the function
std::unique_ptr<statet> tmp_state(make_temporary_state(get_state(l_call)));
tmp_state->transform(
l_call, l_begin, *this, ns, ai_domain_baset::edge_typet::CALL);
tmp_state->transform(l_call, l_begin, *this, ns);

bool new_data=false;

Expand All @@ -445,8 +442,7 @@ bool ai_baset::do_function_call(
return false; // function exit point not reachable

std::unique_ptr<statet> tmp_state(make_temporary_state(end_state));
tmp_state->transform(
l_end, l_return, *this, ns, ai_domain_baset::edge_typet::RETURN);
tmp_state->transform(l_end, l_return, *this, ns);

// Propagate those
return merge(*tmp_state, l_end, l_return);
Expand Down
10 changes: 1 addition & 9 deletions src/analyses/ai.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ class ai_baset;
class ai_domain_baset
{
public:
enum class edge_typet
{
FUNCTION_LOCAL,
CALL,
RETURN,
};

// The constructor is expected to produce 'false'
// or 'bottom'
ai_domain_baset()
Expand All @@ -60,8 +53,7 @@ class ai_domain_baset
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns,
edge_typet edge_type) = 0;
const namespacet &ns)=0;

virtual void output(
std::ostream &out,
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/constant_propagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ void constant_propagator_domaint::transform(
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet /*edge_type*/)
const namespacet &ns)
{
#ifdef DEBUG
std::cout << "Transform from/to:\n";
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/constant_propagator.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class constant_propagator_domaint:public ai_domain_baset
locationt from,
locationt to,
ai_baset &ai_base,
const namespacet &ns,
ai_domain_baset::edge_typet edge_type) final override;
const namespacet &ns) final override;

virtual void output(
std::ostream &out,
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/custom_bitvector_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,7 @@ void custom_bitvector_domaint::transform(
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet /*edge_type*/)
const namespacet &ns)
{
// upcast of ai
custom_bitvector_analysist &cba=
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/custom_bitvector_analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class custom_bitvector_domaint:public ai_domain_baset
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet edge_type) final override;
const namespacet &ns) final override;

void output(
std::ostream &out,
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/dependence_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ void dep_graph_domaint::transform(
goto_programt::const_targett from,
goto_programt::const_targett to,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet /*edge_type*/)
const namespacet &ns)
{
dependence_grapht *dep_graph=dynamic_cast<dependence_grapht*>(&ai);
assert(dep_graph!=nullptr);
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/dependence_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ class dep_graph_domaint:public ai_domain_baset
goto_programt::const_targett from,
goto_programt::const_targett to,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet edge_type) final override;
const namespacet &ns) final override;

void output(
std::ostream &out,
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/escape_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ void escape_domaint::transform(
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet /*edge_type*/)
const namespacet &ns)
{
if(has_values.is_false())
return;
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/escape_analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class escape_domaint:public ai_domain_baset
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet edge_type) final override;
const namespacet &ns) final override;

void output(
std::ostream &out,
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/global_may_alias.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ void global_may_alias_domaint::transform(
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet /*edge_type*/)
const namespacet &ns)
{
if(has_values.is_false())
return;
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/global_may_alias.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class global_may_alias_domaint:public ai_domain_baset
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet edge_type) final override;
const namespacet &ns) final override;

void output(
std::ostream &out,
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/interval_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ void interval_domaint::transform(
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet /*edge_type*/)
const namespacet &ns)
{
const goto_programt::instructiont &instruction=*from;
switch(instruction.type)
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/interval_domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class interval_domaint:public ai_domain_baset
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet edge_type) final override;
const namespacet &ns) final override;

void output(
std::ostream &out,
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/invariant_set_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ void invariant_set_domaint::transform(
locationt from_l,
locationt to_l,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet /*edge_type*/)
const namespacet &ns)
{
switch(from_l->type)
{
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/invariant_set_domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ class invariant_set_domaint:public ai_domain_baset
locationt from_l,
locationt to_l,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet edge_type) final override;
const namespacet &ns) final override;

void make_top() final override
{
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/is_threaded.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ class is_threaded_domaint:public ai_domain_baset
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet /*edge_type*/) final override
const namespacet &ns) final override
{
// assert(reachable);

Expand Down
3 changes: 1 addition & 2 deletions src/analyses/reaching_definitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ void rd_range_domaint::transform(
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet /*edge_type*/)
const namespacet &ns)
{
reaching_definitions_analysist *rd=
dynamic_cast<reaching_definitions_analysist*>(&ai);
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/reaching_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ class rd_range_domaint:public ai_domain_baset
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet edge_type) final override;
const namespacet &ns) final override;

void output(
std::ostream &out,
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/uninitialized_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ void uninitialized_domaint::transform(
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet /*edge_type*/)
const namespacet &ns)
{
if(has_values.is_false())
return;
Expand Down
3 changes: 1 addition & 2 deletions src/analyses/uninitialized_domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class uninitialized_domaint:public ai_domain_baset
locationt from,
locationt to,
ai_baset &ai,
const namespacet &ns,
ai_domain_baset::edge_typet edge_type) final override;
const namespacet &ns) final override;

void output(
std::ostream &out,
Expand Down
7 changes: 1 addition & 6 deletions unit/analyses/ai/ai_simplify_lhs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@
class constant_simplification_mockt:public ai_domain_baset
{
public:
void transform(
locationt,
locationt,
ai_baset &,
const namespacet &,
ai_domain_baset::edge_typet) override
void transform(locationt, locationt, ai_baset &, const namespacet &) override
{}
void make_bottom() override
{}
Expand Down

0 comments on commit 1990994

Please sign in to comment.