Skip to content

Commit 8303a79

Browse files
authored
Merge pull request #6728 from tautschnig/bugfixes/slice-formula
Symex slicing: fixes and cleanup
2 parents c83acfb + c7be7e5 commit 8303a79

File tree

4 files changed

+32
-23
lines changed

4 files changed

+32
-23
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE broken-smt-backend
2+
main.c
3+
--pointer-check --slice-formula
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--

src/goto-symex/show_program.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ static void show_step(
3838
std::string string_value = (step.is_shared_read() || step.is_shared_write())
3939
? from_expr(ns, function_id, step.ssa_lhs)
4040
: from_expr(ns, function_id, step.cond_expr);
41-
std::cout << '(' << count << ") ";
41+
if(step.ignore)
42+
std::cout << "(sliced) ";
43+
else
44+
std::cout << '(' << count << ") ";
4245
if(annotation.empty())
4346
std::cout << string_value;
4447
else

src/goto-symex/slice.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,14 @@ Author: Daniel Kroening, [email protected]
1010
/// Slicer for symex traces
1111

1212
#include "slice.h"
13+
#include "symex_slice_class.h"
1314

15+
#include <util/find_symbols.h>
1416
#include <util/std_expr.h>
1517

16-
#include "symex_slice_class.h"
17-
1818
void symex_slicet::get_symbols(const exprt &expr)
1919
{
20-
get_symbols(expr.type());
21-
22-
forall_operands(it, expr)
23-
get_symbols(*it);
24-
25-
if(expr.id()==ID_symbol)
26-
depends.insert(to_symbol_expr(expr).get_identifier());
27-
}
28-
29-
void symex_slicet::get_symbols(const typet &)
30-
{
31-
// TODO
20+
find_symbols(expr, depends);
3221
}
3322

3423
void symex_slicet::slice(
@@ -44,17 +33,20 @@ void symex_slicet::slice(
4433

4534
void symex_slicet::slice(symex_target_equationt &equation)
4635
{
36+
simple_slice(equation);
37+
4738
for(symex_target_equationt::SSA_stepst::reverse_iterator
4839
it=equation.SSA_steps.rbegin();
4940
it!=equation.SSA_steps.rend();
5041
it++)
51-
slice(*it);
42+
{
43+
if(!it->ignore)
44+
slice(*it);
45+
}
5246
}
5347

5448
void symex_slicet::slice(SSA_stept &SSA_step)
5549
{
56-
get_symbols(SSA_step.guard);
57-
5850
switch(SSA_step.type)
5951
{
6052
case goto_trace_stept::typet::ASSERT:
@@ -66,7 +58,7 @@ void symex_slicet::slice(SSA_stept &SSA_step)
6658
break;
6759

6860
case goto_trace_stept::typet::GOTO:
69-
get_symbols(SSA_step.cond_expr);
61+
// ignore
7062
break;
7163

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

117-
if(depends.find(id)==depends.end())
109+
auto entry = depends.find(id);
110+
if(entry == depends.end())
118111
{
119112
// we don't really need it
120113
SSA_step.ignore=true;
121114
}
122115
else
116+
{
117+
// we have resolved this dependency
118+
depends.erase(entry);
123119
get_symbols(SSA_step.ssa_rhs);
120+
}
124121
}
125122

126123
void symex_slicet::slice_decl(SSA_stept &SSA_step)
@@ -163,6 +160,10 @@ void symex_slicet::collect_open_variables(
163160
get_symbols(SSA_step.cond_expr);
164161
break;
165162

163+
case goto_trace_stept::typet::GOTO:
164+
// ignore
165+
break;
166+
166167
case goto_trace_stept::typet::LOCATION:
167168
// ignore
168169
break;
@@ -175,7 +176,6 @@ void symex_slicet::collect_open_variables(
175176
case goto_trace_stept::typet::OUTPUT:
176177
case goto_trace_stept::typet::INPUT:
177178
case goto_trace_stept::typet::DEAD:
178-
case goto_trace_stept::typet::NONE:
179179
break;
180180

181181
case goto_trace_stept::typet::DECL:
@@ -191,7 +191,7 @@ void symex_slicet::collect_open_variables(
191191
// ignore for now
192192
break;
193193

194-
case goto_trace_stept::typet::GOTO:
194+
case goto_trace_stept::typet::NONE:
195195
UNREACHABLE;
196196
}
197197
}

src/goto-symex/symex_slice_class.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class symex_slicet
3030
symbol_sett depends;
3131

3232
void get_symbols(const exprt &expr);
33-
void get_symbols(const typet &type);
3433

3534
void slice(SSA_stept &SSA_step);
3635
void slice_assignment(SSA_stept &SSA_step);

0 commit comments

Comments
 (0)