Skip to content

Commit 039803d

Browse files
committed
Skip phi assignment if neither merged state has an initialised object
With level-2 counters incremented on declaration and non-deterministic initialisation upon allocation, the only remaining sources are pointer dereferencing, where uninitialised objects necessarily refer to invalid objects. This is a cleaner implementation of 369f077.
1 parent 464566b commit 039803d

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

src/goto-symex/symex_assign.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,6 @@ void goto_symext::symex_assign_symbol(
199199
guardt &guard,
200200
assignment_typet assignment_type)
201201
{
202-
// do not assign to L1 objects that have gone out of scope --
203-
// pointer dereferencing may yield such objects; parameters do not
204-
// have an L2 entry set up beforehand either, so exempt them from
205-
// this check (all other L1 objects should have seen a declaration)
206-
const symbolt *s;
207-
if(!ns.lookup(lhs.get_object_name(), s) &&
208-
!s->is_parameter &&
209-
!lhs.get_level_1().empty() &&
210-
state.level2.current_count(lhs.get_identifier())==0)
211-
return;
212-
213202
exprt ssa_rhs=rhs;
214203

215204
// put assignment guard into the rhs

src/goto-symex/symex_goto.cpp

+14-8
Original file line numberDiff line numberDiff line change
@@ -447,17 +447,23 @@ void goto_symext::phi_function(
447447
// 1. Either guard is false, so we can't follow that branch.
448448
// 2. Either identifier is of generation zero, and so hasn't been
449449
// initialized and therefor an invalid target.
450-
if(dest_state.guard.is_false())
451-
rhs=goto_state_rhs;
452-
else if(goto_state.guard.is_false())
453-
rhs=dest_state_rhs;
454-
else if(goto_state.level2_current_count(l1_identifier) == 0)
450+
if(
451+
dest_state.guard.is_false() ||
452+
dest_state.level2.current_count(l1_identifier) == 0)
455453
{
456-
rhs = dest_state_rhs;
454+
if(goto_state.level2_current_count(l1_identifier) == 0)
455+
continue;
456+
457+
rhs=goto_state_rhs;
457458
}
458-
else if(dest_state.level2.current_count(l1_identifier) == 0)
459+
else if(
460+
goto_state.guard.is_false() ||
461+
goto_state.level2_current_count(l1_identifier) == 0)
459462
{
460-
rhs = goto_state_rhs;
463+
if(dest_state.level2.current_count(l1_identifier) == 0)
464+
continue;
465+
466+
rhs=dest_state_rhs;
461467
}
462468
else
463469
{

0 commit comments

Comments
 (0)