Skip to content

Commit de7f873

Browse files
authored
Merge pull request #5784 from tautschnig/forall-rw_set
Remove forall_rw_set_{r,w}_entries
2 parents 9d398e2 + af7a6e7 commit de7f873

File tree

6 files changed

+117
-94
lines changed

6 files changed

+117
-94
lines changed

.clang-format

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ DerivePointerAlignment: 'false'
3030
DisableFormat: 'false'
3131
ExperimentalAutoDetectBinPacking: 'false'
3232
ForEachMacros: [
33-
'forall_rw_set_r_entries',
34-
'forall_rw_set_w_entries',
3533
'forall_goto_functions',
3634
'Forall_goto_functions',
3735
'forall_goto_program_instructions',

src/goto-instrument/interrupt.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ static bool potential_race_on_read(
2424
const rw_set_baset &isr_rw_set)
2525
{
2626
// R/W race?
27-
forall_rw_set_r_entries(e_it, code_rw_set)
27+
for(const auto &r_entry : code_rw_set.r_entries)
2828
{
29-
if(isr_rw_set.has_w_entry(e_it->first))
29+
if(isr_rw_set.has_w_entry(r_entry.first))
3030
return true;
3131
}
3232

@@ -38,12 +38,12 @@ static bool potential_race_on_write(
3838
const rw_set_baset &isr_rw_set)
3939
{
4040
// W/R or W/W?
41-
forall_rw_set_w_entries(e_it, code_rw_set)
41+
for(const auto &w_entry : code_rw_set.w_entries)
4242
{
43-
if(isr_rw_set.has_r_entry(e_it->first))
43+
if(isr_rw_set.has_r_entry(w_entry.first))
4444
return true;
4545

46-
if(isr_rw_set.has_w_entry(e_it->first))
46+
if(isr_rw_set.has_w_entry(w_entry.first))
4747
return true;
4848
}
4949

src/goto-instrument/race_check.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -193,16 +193,16 @@ static void race_check(
193193
i_it++;
194194

195195
// now add assignments for what is written -- set
196-
forall_rw_set_w_entries(e_it, rw_set)
196+
for(const auto &w_entry : rw_set.w_entries)
197197
{
198-
if(!is_shared(ns, e_it->second.symbol_expr))
198+
if(!is_shared(ns, w_entry.second.symbol_expr))
199199
continue;
200200

201201
goto_programt::targett t = goto_program.insert_before(
202202
i_it,
203203
goto_programt::make_assignment(
204-
w_guards.get_w_guard_expr(e_it->second),
205-
e_it->second.guard,
204+
w_guards.get_w_guard_expr(w_entry.second),
205+
w_entry.second.guard,
206206
original_instruction.source_location));
207207
i_it=++t;
208208
}
@@ -215,46 +215,46 @@ static void race_check(
215215
}
216216

217217
// now add assignments for what is written -- reset
218-
forall_rw_set_w_entries(e_it, rw_set)
218+
for(const auto &w_entry : rw_set.w_entries)
219219
{
220-
if(!is_shared(ns, e_it->second.symbol_expr))
220+
if(!is_shared(ns, w_entry.second.symbol_expr))
221221
continue;
222222

223223
goto_programt::targett t = goto_program.insert_before(
224224
i_it,
225225
goto_programt::make_assignment(
226-
w_guards.get_w_guard_expr(e_it->second),
226+
w_guards.get_w_guard_expr(w_entry.second),
227227
false_exprt(),
228228
original_instruction.source_location));
229229
i_it = std::next(t);
230230
}
231231

232232
// now add assertions for what is read and written
233-
forall_rw_set_r_entries(e_it, rw_set)
233+
for(const auto &r_entry : rw_set.r_entries)
234234
{
235-
if(!is_shared(ns, e_it->second.symbol_expr))
235+
if(!is_shared(ns, r_entry.second.symbol_expr))
236236
continue;
237237

238238
goto_programt::targett t = goto_program.insert_before(
239239
i_it,
240240
goto_programt::make_assertion(
241-
w_guards.get_assertion(e_it->second),
241+
w_guards.get_assertion(r_entry.second),
242242
original_instruction.source_location));
243-
t->source_location.set_comment(comment(e_it->second, false));
243+
t->source_location.set_comment(comment(r_entry.second, false));
244244
i_it=++t;
245245
}
246246

247-
forall_rw_set_w_entries(e_it, rw_set)
247+
for(const auto &w_entry : rw_set.w_entries)
248248
{
249-
if(!is_shared(ns, e_it->second.symbol_expr))
249+
if(!is_shared(ns, w_entry.second.symbol_expr))
250250
continue;
251251

252252
goto_programt::targett t = goto_program.insert_before(
253253
i_it,
254254
goto_programt::make_assertion(
255-
w_guards.get_assertion(e_it->second),
255+
w_guards.get_assertion(w_entry.second),
256256
original_instruction.source_location));
257-
t->source_location.set_comment(comment(e_it->second, true));
257+
t->source_location.set_comment(comment(w_entry.second, true));
258258
i_it=++t;
259259
}
260260

src/goto-instrument/rw_set.h

-8
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,6 @@ inline std::ostream &operator<<(
107107
return out;
108108
}
109109

110-
#define forall_rw_set_r_entries(it, rw_set) \
111-
for(rw_set_baset::entriest::const_iterator it=(rw_set).r_entries.begin(); \
112-
it!=(rw_set).r_entries.end(); it++)
113-
114-
#define forall_rw_set_w_entries(it, rw_set) \
115-
for(rw_set_baset::entriest::const_iterator it=(rw_set).w_entries.begin(); \
116-
it!=(rw_set).w_entries.end(); it++)
117-
118110
// a producer of read/write sets
119111

120112
class _rw_set_loct:public rw_set_baset

src/goto-instrument/wmm/goto2graph.cpp

+20-16
Original file line numberDiff line numberDiff line change
@@ -436,19 +436,19 @@ bool instrumentert::cfg_visitort::contains_shared_array(
436436
instrumenter.message.debug() << "Writes: "<<rw_set.w_entries.size()
437437
<<"; Reads:"<<rw_set.r_entries.size() << messaget::eom;
438438

439-
forall_rw_set_r_entries(r_it, rw_set)
439+
for(const auto &r_entry : rw_set.r_entries)
440440
{
441-
const irep_idt var=r_it->second.object;
441+
const irep_idt var = r_entry.second.object;
442442
instrumenter.message.debug() << "Is "<<var<<" an array?"
443443
<< messaget::eom;
444444
if(id2string(var).find("[]")!=std::string::npos
445445
&& !instrumenter.local(var))
446446
return true;
447447
}
448448

449-
forall_rw_set_w_entries(w_it, rw_set)
449+
for(const auto &w_entry : rw_set.w_entries)
450450
{
451-
const irep_idt var=w_it->second.object;
451+
const irep_idt var = w_entry.second.object;
452452
instrumenter.message.debug()<<"Is "<<var<<" an array?"<<messaget::eom;
453453
if(id2string(var).find("[]")!=std::string::npos
454454
&& !instrumenter.local(var))
@@ -874,13 +874,13 @@ void instrumentert::cfg_visitort::visit_cfg_assign(
874874
continue; // return;
875875
#endif
876876

877-
forall_rw_set_r_entries(r_it, rw_set)
877+
for(const auto &r_entry : rw_set.r_entries)
878878
{
879879
/* creates Read:
880880
read is the irep_id of the read in the code;
881881
new_read_event is the corresponding abstract event;
882882
new_read_node is the node in the graph */
883-
const irep_idt &read=r_it->second.object;
883+
const irep_idt &read = r_entry.second.object;
884884

885885
/* skip local variables */
886886
if(local(read))
@@ -976,13 +976,13 @@ void instrumentert::cfg_visitort::visit_cfg_assign(
976976
}
977977

978978
/* Write (Wa) */
979-
forall_rw_set_w_entries(w_it, rw_set)
979+
for(const auto &w_entry : rw_set.w_entries)
980980
{
981981
/* creates Write:
982982
write is the irep_id in the code;
983983
new_write_event is the corresponding abstract event;
984984
new_write_node is the node in the graph */
985-
const irep_idt &write=w_it->second.object;
985+
const irep_idt &write = w_entry.second.object;
986986

987987
instrumenter.message.debug() << "WRITE: " << write << messaget::eom;
988988

@@ -1142,30 +1142,34 @@ void instrumentert::cfg_visitort::visit_cfg_assign(
11421142
/* data dependency analysis */
11431143
if(!no_dependencies)
11441144
{
1145-
forall_rw_set_w_entries(write_it, rw_set)
1146-
forall_rw_set_r_entries(read_it, rw_set)
1145+
for(const auto &w_entry : rw_set.w_entries)
1146+
{
1147+
for(const auto &r_entry : rw_set.r_entries)
11471148
{
1148-
const irep_idt &write=write_it->second.object;
1149-
const irep_idt &read=read_it->second.object;
1149+
const irep_idt &write = w_entry.second.object;
1150+
const irep_idt &read = r_entry.second.object;
11501151
instrumenter.message.debug() << "dp: Write:"<<write<<"; Read:"<<read
11511152
<< messaget::eom;
11521153
const datat read_p(read, instruction.source_location);
11531154
const datat write_p(write, instruction.source_location);
11541155
data_dp.dp_analysis(read_p, local(read), write_p, local(write));
11551156
}
1157+
}
11561158
data_dp.dp_merge();
11571159

1158-
forall_rw_set_r_entries(read2_it, rw_set)
1159-
forall_rw_set_r_entries(read_it, rw_set)
1160+
for(const auto &r_entry : rw_set.r_entries)
1161+
{
1162+
for(const auto &r_entry2 : rw_set.r_entries)
11601163
{
1161-
const irep_idt &read2=read2_it->second.object;
1162-
const irep_idt &read=read_it->second.object;
1164+
const irep_idt &read2 = r_entry2.second.object;
1165+
const irep_idt &read = r_entry.second.object;
11631166
if(read2==read)
11641167
continue;
11651168
const datat read_p(read, instruction.source_location);
11661169
const datat read2_p(read2, instruction.source_location);
11671170
data_dp.dp_analysis(read_p, local(read), read2_p, local(read2));
11681171
}
1172+
}
11691173
data_dp.dp_merge();
11701174
}
11711175
}

0 commit comments

Comments
 (0)