@@ -16,8 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com
1616#include < util/rename.h>
1717#include < util/std_expr.h>
1818
19- #include < pointer-analysis/add_failed_symbols.h>
20-
2119#include < analyses/dirty.h>
2220
2321void goto_symext::symex_decl (statet &state)
@@ -51,37 +49,23 @@ void goto_symext::symex_decl(statet &state, const symbol_exprt &expr)
5149 state.rename (ssa.type (), l1_identifier, ns);
5250 ssa.update_type ();
5351
54- // in case of pointers, put something into the value set
55- if (ns.follow (expr.type ()).id ()==ID_pointer)
56- {
57- exprt failed=
58- get_failed_symbol (expr, ns);
59-
60- exprt rhs;
61-
62- if (failed.is_not_nil ())
63- rhs=address_of_exprt (failed, to_pointer_type (expr.type ()));
64- else
65- rhs=exprt (ID_invalid);
66-
67- state.rename (rhs, ns, goto_symex_statet::L1);
68- state.value_set .assign (ssa, rhs, ns, true , false );
69- }
70-
71- // prevent propagation
72- state.propagation .remove (l1_identifier);
73-
7452 // L2 renaming
7553 // inlining may yield multiple declarations of the same identifier
7654 // within the same L1 context
7755 if (state.level2 .current_names .find (l1_identifier)==
7856 state.level2 .current_names .end ())
7957 state.level2 .current_names [l1_identifier]=std::make_pair (ssa, 0 );
80- state.level2 .increase_counter (l1_identifier);
81- const bool record_events=state.record_events ;
82- state.record_events =false ;
83- state.rename (ssa, ns);
84- state.record_events =record_events;
58+ init_l1 = l1_identifier;
59+
60+ // optimisation: skip non-deterministic initialisation if the next instruction
61+ // will take care of initialisation (but ensure int x=x; is handled properly)
62+ goto_programt::const_targett next = std::next (state.source .pc );
63+ if (
64+ next->is_assign () && to_code_assign (next->code ).lhs () == expr &&
65+ to_code_assign (next->code ).rhs ().is_constant ())
66+ {
67+ return ;
68+ }
8569
8670 // we hide the declaration of auxiliary variables
8771 // and if the statement itself is hidden
@@ -90,10 +74,16 @@ void goto_symext::symex_decl(statet &state, const symbol_exprt &expr)
9074 state.top ().hidden_function ||
9175 state.source .pc ->source_location .get_hide ();
9276
93- target.decl (
94- state.guard .as_expr (),
77+ side_effect_expr_nondett init (ssa.type ());
78+ replace_nondet (init);
79+
80+ guardt guard;
81+ symex_assign_symbol (
82+ state,
9583 ssa,
96- state.source ,
84+ nil_exprt (),
85+ init,
86+ guard,
9787 hidden?
9888 symex_targett::assignment_typet::HIDDEN:
9989 symex_targett::assignment_typet::STATE);
0 commit comments