Skip to content

Symex slicing: fixes and cleanup #6728

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
merged 1 commit into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions regression/cbmc/Malloc11/slice-formula.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CORE broken-smt-backend
main.c
--pointer-check --slice-formula
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
5 changes: 4 additions & 1 deletion src/goto-symex/show_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ static void show_step(
std::string string_value = (step.is_shared_read() || step.is_shared_write())
? from_expr(ns, function_id, step.ssa_lhs)
: from_expr(ns, function_id, step.cond_expr);
std::cout << '(' << count << ") ";
if(step.ignore)
std::cout << "(sliced) ";
else
std::cout << '(' << count << ") ";
if(annotation.empty())
std::cout << string_value;
else
Expand Down
42 changes: 21 additions & 21 deletions src/goto-symex/slice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,14 @@ Author: Daniel Kroening, [email protected]
/// Slicer for symex traces

#include "slice.h"
#include "symex_slice_class.h"

#include <util/find_symbols.h>
#include <util/std_expr.h>

#include "symex_slice_class.h"

void symex_slicet::get_symbols(const exprt &expr)
{
get_symbols(expr.type());

forall_operands(it, expr)
get_symbols(*it);

if(expr.id()==ID_symbol)
depends.insert(to_symbol_expr(expr).get_identifier());
}

void symex_slicet::get_symbols(const typet &)
{
// TODO
find_symbols(expr, depends);
}

void symex_slicet::slice(
Expand All @@ -44,17 +33,20 @@ void symex_slicet::slice(

void symex_slicet::slice(symex_target_equationt &equation)
{
simple_slice(equation);

for(symex_target_equationt::SSA_stepst::reverse_iterator
it=equation.SSA_steps.rbegin();
it!=equation.SSA_steps.rend();
it++)
slice(*it);
{
if(!it->ignore)
slice(*it);
}
}

void symex_slicet::slice(SSA_stept &SSA_step)
{
get_symbols(SSA_step.guard);

switch(SSA_step.type)
{
case goto_trace_stept::typet::ASSERT:
Expand All @@ -66,7 +58,7 @@ void symex_slicet::slice(SSA_stept &SSA_step)
break;

case goto_trace_stept::typet::GOTO:
get_symbols(SSA_step.cond_expr);
// ignore
break;

case goto_trace_stept::typet::LOCATION:
Expand Down Expand Up @@ -114,13 +106,18 @@ void symex_slicet::slice_assignment(SSA_stept &SSA_step)
PRECONDITION(SSA_step.ssa_lhs.id() == ID_symbol);
const irep_idt &id=SSA_step.ssa_lhs.get_identifier();

if(depends.find(id)==depends.end())
auto entry = depends.find(id);
if(entry == depends.end())
{
// we don't really need it
SSA_step.ignore=true;
}
else
{
// we have resolved this dependency
depends.erase(entry);
get_symbols(SSA_step.ssa_rhs);
}
}

void symex_slicet::slice_decl(SSA_stept &SSA_step)
Expand Down Expand Up @@ -163,6 +160,10 @@ void symex_slicet::collect_open_variables(
get_symbols(SSA_step.cond_expr);
break;

case goto_trace_stept::typet::GOTO:
// ignore
break;

case goto_trace_stept::typet::LOCATION:
// ignore
break;
Expand All @@ -175,7 +176,6 @@ void symex_slicet::collect_open_variables(
case goto_trace_stept::typet::OUTPUT:
case goto_trace_stept::typet::INPUT:
case goto_trace_stept::typet::DEAD:
case goto_trace_stept::typet::NONE:
break;

case goto_trace_stept::typet::DECL:
Expand All @@ -191,7 +191,7 @@ void symex_slicet::collect_open_variables(
// ignore for now
break;

case goto_trace_stept::typet::GOTO:
case goto_trace_stept::typet::NONE:
UNREACHABLE;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/goto-symex/symex_slice_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class symex_slicet
symbol_sett depends;

void get_symbols(const exprt &expr);
void get_symbols(const typet &type);

void slice(SSA_stept &SSA_step);
void slice_assignment(SSA_stept &SSA_step);
Expand Down