@@ -40,7 +40,7 @@ void goto_symext::symex_start_thread(statet &state)
40
40
instruction.get_target ();
41
41
42
42
// put into thread vector
43
- std::size_t t= state.threads .size ();
43
+ const std::size_t new_thread_nr = state.threads .size ();
44
44
state.threads .push_back (statet::threadt (guard_manager));
45
45
// statet::threadt &cur_thread=state.threads[state.source.thread_nr];
46
46
statet::threadt &new_thread=state.threads .back ();
@@ -54,6 +54,8 @@ void goto_symext::symex_start_thread(statet &state)
54
54
new_thread.abstract_events=&(target.new_thread(cur_thread.abstract_events));
55
55
#endif
56
56
57
+ const std::size_t current_thread_nr = state.source .thread_nr ;
58
+
57
59
// create a copy of the local variables for the new thread
58
60
framet &frame = state.call_stack ().top ();
59
61
@@ -72,7 +74,8 @@ void goto_symext::symex_start_thread(statet &state)
72
74
ssa_exprt lhs (pair.second .first .get_original_expr ());
73
75
74
76
// get L0 name for current thread
75
- const renamedt<ssa_exprt, L0> l0_lhs = symex_level0 (std::move (lhs), ns, t);
77
+ const renamedt<ssa_exprt, L0> l0_lhs =
78
+ symex_level0 (std::move (lhs), ns, new_thread_nr);
76
79
const irep_idt &l0_name = l0_lhs.get ().get_identifier ();
77
80
std::size_t l1_index = path_storage.get_unique_l1_index (l0_name, 0 );
78
81
CHECK_RETURN (l1_index == 0 );
@@ -93,7 +96,20 @@ void goto_symext::symex_start_thread(statet &state)
93
96
symex_assignt{
94
97
state, symex_targett::assignment_typet::HIDDEN, ns, symex_config, target}
95
98
.assign_symbol (lhs_l1, expr_skeletont{}, rhs, lhs_conditions);
99
+ const exprt l2_lhs = state.rename (lhs_l1, ns).get ();
96
100
state.record_events .pop ();
101
+
102
+ // record a shared write in the new thread
103
+ if (
104
+ state.write_is_shared (lhs_l1, ns) ==
105
+ goto_symex_statet::write_is_shared_resultt::SHARED &&
106
+ is_ssa_expr (l2_lhs))
107
+ {
108
+ state.source .thread_nr = new_thread_nr;
109
+ target.shared_write (
110
+ state.guard .as_expr (), to_ssa_expr (l2_lhs), 0 , state.source );
111
+ state.source .thread_nr = current_thread_nr;
112
+ }
97
113
}
98
114
99
115
// initialize all variables marked thread-local
@@ -112,7 +128,7 @@ void goto_symext::symex_start_thread(statet &state)
112
128
ssa_exprt lhs (symbol.symbol_expr ());
113
129
114
130
// get L0 name for current thread
115
- lhs.set_level_0 (t );
131
+ lhs.set_level_0 (new_thread_nr );
116
132
117
133
exprt rhs=symbol.value ;
118
134
if (rhs.is_nil ())
0 commit comments