Skip to content

Commit 874f6ce

Browse files
committed
Symex slicing: fixes and cleanup
Symex slicing previously failed to track symbols appearing in types. This commit resolves this "TODO" and replaces the implementation by find_symbols, which knows how to get this right. Also make sure we don't unnecessarily track goto guards when the path condition is made part of the assertion anyway. Employ simple_slice before doing symbol-based slicing to avoid dragging in unnecessary dependencies from after the last assertion.
1 parent 3f7f5ae commit 874f6ce

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
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/slice.cpp

Lines changed: 17 additions & 20 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,6 +33,8 @@ 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();
@@ -53,8 +44,6 @@ void symex_slicet::slice(symex_target_equationt &equation)
5344

5445
void symex_slicet::slice(SSA_stept &SSA_step)
5546
{
56-
get_symbols(SSA_step.guard);
57-
5847
switch(SSA_step.type)
5948
{
6049
case goto_trace_stept::typet::ASSERT:
@@ -66,7 +55,7 @@ void symex_slicet::slice(SSA_stept &SSA_step)
6655
break;
6756

6857
case goto_trace_stept::typet::GOTO:
69-
get_symbols(SSA_step.cond_expr);
58+
// ignore
7059
break;
7160

7261
case goto_trace_stept::typet::LOCATION:
@@ -114,13 +103,18 @@ void symex_slicet::slice_assignment(SSA_stept &SSA_step)
114103
PRECONDITION(SSA_step.ssa_lhs.id() == ID_symbol);
115104
const irep_idt &id=SSA_step.ssa_lhs.get_identifier();
116105

117-
if(depends.find(id)==depends.end())
106+
auto entry = depends.find(id);
107+
if(entry == depends.end())
118108
{
119109
// we don't really need it
120110
SSA_step.ignore=true;
121111
}
122112
else
113+
{
114+
// we have resolved this dependency
115+
depends.erase(entry);
123116
get_symbols(SSA_step.ssa_rhs);
117+
}
124118
}
125119

126120
void symex_slicet::slice_decl(SSA_stept &SSA_step)
@@ -163,6 +157,10 @@ void symex_slicet::collect_open_variables(
163157
get_symbols(SSA_step.cond_expr);
164158
break;
165159

160+
case goto_trace_stept::typet::GOTO:
161+
// ignore
162+
break;
163+
166164
case goto_trace_stept::typet::LOCATION:
167165
// ignore
168166
break;
@@ -175,7 +173,6 @@ void symex_slicet::collect_open_variables(
175173
case goto_trace_stept::typet::OUTPUT:
176174
case goto_trace_stept::typet::INPUT:
177175
case goto_trace_stept::typet::DEAD:
178-
case goto_trace_stept::typet::NONE:
179176
break;
180177

181178
case goto_trace_stept::typet::DECL:
@@ -191,7 +188,7 @@ void symex_slicet::collect_open_variables(
191188
// ignore for now
192189
break;
193190

194-
case goto_trace_stept::typet::GOTO:
191+
case goto_trace_stept::typet::NONE:
195192
UNREACHABLE;
196193
}
197194
}

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)