16
16
#include < util/rename.h>
17
17
#include < util/std_expr.h>
18
18
19
- #include < pointer-analysis/add_failed_symbols.h>
20
-
21
19
#include < analyses/dirty.h>
22
20
23
21
void goto_symext::symex_decl (statet &state)
@@ -51,37 +49,23 @@ void goto_symext::symex_decl(statet &state, const symbol_exprt &expr)
51
49
state.rename (ssa.type (), l1_identifier, ns);
52
50
ssa.update_type ();
53
51
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
-
74
52
// L2 renaming
75
53
// inlining may yield multiple declarations of the same identifier
76
54
// within the same L1 context
77
55
if (state.level2 .current_names .find (l1_identifier)==
78
56
state.level2 .current_names .end ())
79
57
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
+ }
85
69
86
70
// we hide the declaration of auxiliary variables
87
71
// and if the statement itself is hidden
@@ -90,10 +74,16 @@ void goto_symext::symex_decl(statet &state, const symbol_exprt &expr)
90
74
state.top ().hidden_function ||
91
75
state.source .pc ->source_location .get_hide ();
92
76
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,
95
83
ssa,
96
- state.source ,
84
+ nil_exprt (),
85
+ init,
86
+ guard,
97
87
hidden?
98
88
symex_targett::assignment_typet::HIDDEN:
99
89
symex_targett::assignment_typet::STATE);
0 commit comments