Skip to content

Commit 63936ad

Browse files
smowtontautschnig
authored andcommitted
Move field expansion outside goto_symex_statet::assignment
Otherwise while everything works correctly for the state, the target sees the field expansions before the composite definition, which is a problem if the values are non-constant and so the expansion RHSes refer to the composite!
1 parent 792cde3 commit 63936ad

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

src/goto-symex/goto_symex_state.cpp

-12
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,6 @@ void goto_symex_statet::assignment(
222222
value_set.assign(l1_lhs, l1_rhs, ns, rhs_is_simplified, is_shared);
223223
}
224224

225-
if(field_sensitivityt::is_divisible(l1_lhs))
226-
{
227-
// Split composite symbol lhs into its components
228-
field_sensitivity.field_assignments(
229-
ns, *this, l1_lhs, *symex_target, allow_pointer_unsoundness);
230-
// Erase the composite symbol from our working state. Note that we need to
231-
// have it in the propagation table and the value set while doing the field
232-
// assignments, thus we cannot skip putting it in there above.
233-
propagation.erase(l1_identifier);
234-
value_set.erase_symbol(l1_lhs, ns);
235-
}
236-
237225
#if 0
238226
std::cout << "Assigning " << l1_identifier << '\n';
239227
value_set.output(ns, std::cout);

src/goto-symex/symex_assign.cpp

+21-11
Original file line numberDiff line numberDiff line change
@@ -390,35 +390,33 @@ void goto_symext::symex_assign_symbol(
390390

391391
do_simplify(l2_rhs);
392392

393-
ssa_exprt ssa_lhs = lhs_mod;
393+
ssa_exprt l2_lhs = lhs_mod;
394+
ssa_exprt l1_lhs = l2_lhs; // l2_lhs will be renamed to L2 by the following:
394395
state.assignment(
395-
ssa_lhs,
396+
l2_lhs,
396397
l2_rhs,
397398
ns,
398399
symex_config.simplify_opt,
399400
symex_config.constant_propagation,
400401
symex_config.allow_pointer_unsoundness);
401402

402403
exprt ssa_full_lhs=full_lhs;
403-
ssa_full_lhs=add_to_lhs(ssa_full_lhs, ssa_lhs);
404+
ssa_full_lhs = add_to_lhs(ssa_full_lhs, l2_lhs);
404405
const bool record_events=state.record_events;
405406
state.record_events=false;
406407
exprt l2_full_lhs = state.rename(std::move(ssa_full_lhs), ns).get();
407408
state.record_events=record_events;
408409

409410
// do the assignment
410-
const symbolt &symbol = ns.lookup(ssa_lhs.get_object_name());
411+
const symbolt &symbol = ns.lookup(l2_lhs.get_object_name());
411412

412413
if(symbol.is_auxiliary)
413414
assignment_type=symex_targett::assignment_typet::HIDDEN;
414415

415416
log.conditional_output(
416-
log.debug(),
417-
[this, &ssa_lhs](messaget::mstreamt &mstream) {
418-
mstream << "Assignment to " << ssa_lhs.get_identifier()
419-
<< " ["
420-
<< pointer_offset_bits(ssa_lhs.type(), ns).value_or(0)
421-
<< " bits]"
417+
log.debug(), [this, &l2_lhs](messaget::mstreamt &mstream) {
418+
mstream << "Assignment to " << l2_lhs.get_identifier() << " ["
419+
<< pointer_offset_bits(l2_lhs.type(), ns).value_or(0) << " bits]"
422420
<< messaget::eom;
423421
});
424422

@@ -429,13 +427,25 @@ void goto_symext::symex_assign_symbol(
429427
get_original_name(original_lhs);
430428
target.assignment(
431429
conjunction(guard),
432-
ssa_lhs,
430+
l2_lhs,
433431
l2_full_lhs,
434432
original_lhs,
435433
l2_rhs,
436434
state.source,
437435
assignment_type);
438436

437+
if(field_sensitivityt::is_divisible(l1_lhs))
438+
{
439+
// Split composite symbol lhs into its components
440+
state.field_sensitivity.field_assignments(
441+
ns, state, l1_lhs, target, symex_config.allow_pointer_unsoundness);
442+
// Erase the composite symbol from our working state. Note that we need to
443+
// have it in the propagation table and the value set while doing the field
444+
// assignments, thus we cannot skip putting it in there above.
445+
state.propagation.erase(l1_lhs.get_identifier());
446+
state.value_set.erase_symbol(l1_lhs, ns);
447+
}
448+
439449
// Restore the guard
440450
guard.pop_back();
441451
}

0 commit comments

Comments
 (0)