47 identifier==
"stdin" ||
48 identifier==
"stdout" ||
49 identifier==
"stderr" ||
50 identifier==
"sys_nerr" ||
54 const size_t pos=identifier.find(
"[]");
56 if(
pos!=std::string::npos)
59 identifier.erase(
pos);
74 catch(
const std::string &exception)
99 visitor.
visit_cfg(value_sets, model, no_dependencies, duplicate_body,
102 std::vector<std::size_t> subgraph_index;
106 for(std::map<event_idt, event_idt>::const_iterator
111 const std::size_t sg=subgraph_index[it->second];
119 unsigned interesting_sccs=0;
125 << interesting_sccs <<
" interesting SCCs"
136 std::size_t instr_counter=0;
137 for(goto_functionst::function_mapt::const_iterator
141 instr_counter+=it->second.body.instructions.size();
151 bool no_dependencies,
154 std::set<instrumentert::cfg_visitort::nodet> &ending_vertex)
158 instrumenter.message.debug()
168 instrumenter.goto_functions.function_map[function_id]);
173 instrumenter.goto_functions.function_map[function_id].body;
181 max_thread=max_thread+1;
182 coming_from=current_thread;
183 current_thread=max_thread;
186 current_thread=coming_from;
187 thread=current_thread;
189 instrumenter.message.debug()
202 #elif defined ATOMIC_FENCE
203 visit_cfg_fence(i_it, function_id);
206 visit_cfg_propagate(i_it);
223 else if(
is_fence(instruction, instrumenter.ns))
225 instrumenter.message.debug() <<
"Constructing a fence" <<
messaget::eom;
226 visit_cfg_fence(i_it, function_id);
228 else if(model!=
TSO &&
is_lwfence(instruction, instrumenter.ns))
230 visit_cfg_lwfence(i_it, function_id);
232 else if(model==
TSO &&
is_lwfence(instruction, instrumenter.ns))
235 visit_cfg_skip(i_it);
241 visit_cfg_asm_fence(i_it, function_id);
245 visit_cfg_function_call(value_sets, i_it, model,
246 no_dependencies, replicate_body);
262 #ifdef CONTEXT_INSENSITIVE
265 visit_cfg_propagate(i_it);
266 add_all_pos(it, out_nodes[function_id], in_pos[i_it]);
272 visit_cfg_propagate(i_it);
276 std::pair<unsigned, data_dpt> new_dp(thread, data_dp);
278 data_dp.print(instrumenter.message);
280 if(instrumenter.goto_functions.function_map[function_id]
281 .body.instructions.empty())
287 goto_programt::instructionst::iterator it =
288 instrumenter.goto_functions.function_map[function_id]
289 .body.instructions.end();
291 ending_vertex=in_pos[it];
296 goto_programt::instructionst::iterator i_it)
300 in_pos[i_it].
clear();
302 if(in_pos.find(in)!=in_pos.end())
303 for(
const auto &node : in_pos[in])
304 in_pos[i_it].insert(node);
320 if(instrumenter.map_function_graph.find(id_function)!=
321 instrumenter.map_function_graph.end())
326 .function_map[id_function].body.instructions;
335 goto_programt::instructionst::iterator i_it=body.end();
339 goto_programt::instructionst::iterator targ=body.begin();
341 std::set<event_idt> in_nodes;
342 std::set<event_idt> out_nodes;
345 if(in_pos.find(targ)!=in_pos.end())
348 if(updated.find(targ)!=updated.end())
351 for(std::set<nodet>::const_iterator to=in_pos[targ].begin();
352 to!=in_pos[targ].end(); ++to)
353 in_nodes.insert(to->first);
354 for(std::set<nodet>::const_iterator from=in_pos[i_it].begin();
355 from!=in_pos[i_it].end(); ++from)
356 out_nodes.insert(from->first);
360 instrumenter.message.debug() <<
"else case" <<
messaget::eom;
362 for(goto_programt::instructionst::iterator cur=i_it;
366 for(
const auto &in : cur->incoming_edges)
369 if(in_pos.find(in)!=in_pos.end() &&
370 updated.find(in)!=updated.end())
375 else if(in_pos.find(in)!=in_pos.end())
384 if(out_pos.find(targ)!=out_pos.end())
386 for(std::set<nodet>::const_iterator to=out_pos[targ].begin();
387 to!=out_pos[targ].end(); ++to)
388 in_nodes.insert(to->first);
389 for(std::set<nodet>::const_iterator from=in_pos[i_it].begin();
390 from!=in_pos[i_it].end(); ++from)
391 out_nodes.insert(from->first);
396 instrumenter.map_function_graph[id_function]=
397 std::make_pair(in_nodes, out_nodes);
420 instrumenter.message.debug()
421 <<
"contains_shared_array called for " << targ->source_location().get_line()
422 <<
" and " << i_it->source_location().get_line() <<
messaget::eom;
425 instrumenter.message.debug()
426 <<
"Do we have an array at line " << cur->source_location().get_line()
438 instrumenter.message.debug() <<
"Writes: "<<rw_set.
w_entries.size()
441 for(
const auto &r_entry : rw_set.
r_entries)
443 const irep_idt var = r_entry.second.object;
444 instrumenter.message.debug() <<
"Is "<<var<<
" an array?"
446 if(
id2string(var).find(
"[]")!=std::string::npos
447 && !instrumenter.local(var))
451 for(
const auto &w_entry : rw_set.
w_entries)
453 const irep_idt var = w_entry.second.object;
454 instrumenter.message.debug()<<
"Is "<<var<<
" an array?"<<
messaget::eom;
455 if(
id2string(var).find(
"[]")!=std::string::npos
456 && !instrumenter.local(var))
479 for(
const auto &target : i_it->targets)
482 if(in_pos.find(target)!=in_pos.end())
484 if(in_pos[i_it].empty())
487 bool duplicate_this=
false;
489 switch(replicate_body)
492 duplicate_this = contains_shared_array(
507 duplicate_this=
false;
512 visit_cfg_duplicate(goto_program, target, i_it);
514 visit_cfg_backedge(target, i_it);
524 instrumenter.message.status() <<
"Duplication..." <<
messaget::eom;
526 bool found_pos=
false;
529 if(in_pos[targ].empty())
532 for(; new_targ != goto_program.
instructions.end(); ++new_targ)
534 if(in_pos.find(new_targ)!=in_pos.end() && !in_pos[new_targ].empty())
546 new_targ->source_location().get_function() !=
547 targ->source_location().get_function() ||
548 new_targ->source_location().get_file() !=
549 targ->source_location().get_file())
554 const std::set<nodet> &up_set=in_pos[(found_pos ? new_targ : targ)];
555 const std::set<nodet> &down_set=in_pos[i_it];
557 for(std::set<nodet>::const_iterator begin_it=up_set.begin();
558 begin_it!=up_set.end(); ++begin_it)
559 instrumenter.message.debug() <<
"Up " << begin_it->first <<
messaget::eom;
561 for(std::set<nodet>::const_iterator begin_it=down_set.begin();
562 begin_it!=down_set.end(); ++begin_it)
563 instrumenter.message.debug() <<
"Down " << begin_it->first <<
messaget::eom;
565 for(std::set<nodet>::const_iterator begin_it=up_set.begin();
566 begin_it!=up_set.end(); ++begin_it)
568 for(std::set<nodet>::const_iterator end_it=down_set.begin();
569 end_it!=down_set.end(); ++end_it)
590 if(updated.find(targ)!=updated.end())
593 for(std::set<nodet>::const_iterator to=in_pos[targ].begin();
594 to!=in_pos[targ].end(); ++to)
595 for(std::set<nodet>::const_iterator from=in_pos[i_it].begin();
596 from!=in_pos[i_it].end(); ++from)
597 if(from->first!=to->first)
599 if(
egraph[from->first].thread!=
egraph[to->first].thread)
601 instrumenter.message.debug() << from->first <<
"-po->"
609 instrumenter.message.debug() <<
"else case" <<
messaget::eom;
615 for(
const auto &in : cur->incoming_edges)
617 if(in_pos.find(in)!=in_pos.end()
618 && updated.find(in)!=updated.end())
623 else if(in_pos.find(in)!=in_pos.end())
632 if(out_pos.find(targ)!=out_pos.end())
634 for(std::set<nodet>::const_iterator to=out_pos[targ].begin();
635 to!=out_pos[targ].end(); ++to)
636 for(std::set<nodet>::const_iterator from=in_pos[i_it].begin();
637 from!=in_pos[i_it].end(); ++from)
638 if(from->first!=to->first)
640 if(
egraph[from->first].thread!=
egraph[to->first].thread)
642 instrumenter.message.debug() << from->first<<
"-po->"
654 goto_programt::instructionst::iterator i_it,
666 visit_cfg_propagate(i_it);
674 instrumenter.message.debug() <<
"backward goto" <<
messaget::eom;
691 goto_programt::instructionst::iterator i_it,
693 bool no_dependencies,
703 enter_function(fun_id);
704 #ifdef CONTEXT_INSENSITIVE
705 stack_fun.push(cur_fun);
710 if(!inline_function_cond(fun_id))
714 if(instrumenter.map_function_graph.find(fun_id)!=
715 instrumenter.map_function_graph.end())
724 visit_cfg_function(value_sets, model, no_dependencies, fun_id,
726 updated.insert(i_it);
733 visit_cfg_function(value_sets, model, no_dependencies, replicate_body,
734 fun_id, in_pos[i_it]);
735 updated.insert(i_it);
738 leave_function(fun_id);
739 #ifdef CONTEXT_INSENSITIVE
740 cur_fun=stack_fun.pop();
743 catch(
const std::string &s)
745 instrumenter.message.warning() <<
"sorry, doesn't handle recursion "
746 <<
"(function " << fun_id <<
"; .cpp) "
752 goto_programt::instructionst::iterator i_it,
760 instrumenter.unique_id++,
765 egraph[new_fence_node](new_fence_event);
768 instrumenter.map_vertex_gnode.insert(
769 std::make_pair(new_fence_node, new_fence_gnode));
772 if(in_pos.find(in)!=in_pos.end())
774 for(
const auto &node : in_pos[in])
776 if(
egraph[node.first].thread!=thread)
778 instrumenter.message.debug() << node.first<<
"-po->"<<new_fence_node
785 in_pos[i_it].clear();
786 in_pos[i_it].insert(
nodet(new_fence_node, new_fence_gnode));
787 updated.insert(i_it);
791 goto_programt::instructionst::iterator i_it,
806 instrumenter.unique_id++,
818 egraph[new_fence_node](new_fence_event);
821 instrumenter.map_vertex_gnode.insert(
822 std::make_pair(new_fence_node, new_fence_gnode));
825 if(in_pos.find(in)!=in_pos.end())
827 for(
const auto &node : in_pos[in])
829 if(
egraph[node.first].thread!=thread)
831 instrumenter.message.debug() << node.first<<
"-po->"<<new_fence_node
838 in_pos[i_it].clear();
839 in_pos[i_it].insert(
nodet(new_fence_node, new_fence_gnode));
840 updated.insert(i_it);
846 goto_programt::instructionst::iterator &i_it,
868 event_idt previous=std::numeric_limits<event_idt>::max();
869 event_idt previous_gnode=std::numeric_limits<event_idt>::max();
876 if(!instruction.
labels.empty() && instruction.
labels.front()==
"ASSERT")
880 for(
const auto &r_entry : rw_set.
r_entries)
886 const irep_idt &read = r_entry.second.object;
901 instrumenter.unique_id++,
907 egraph[new_read_node]=new_read_event;
908 instrumenter.message.debug() <<
"new Read" << read <<
" @thread" << (thread)
910 << (
local(read) ?
"local" :
"shared") <<
") #"
914 unknown_read_nodes.insert(new_read_node);
918 instrumenter.map_vertex_gnode.insert(
919 std::make_pair(new_read_node, new_read_gnode));
924 if(in_pos.find(in)!=in_pos.end())
926 for(
const auto &node : in_pos[in])
928 if(
egraph[node.first].thread!=thread)
930 instrumenter.message.debug() << node.first<<
"-po->"
939 previous=new_read_node;
940 previous_gnode=new_read_gnode;
943 const std::pair<id2nodet::iterator, id2nodet::iterator>
944 with_same_var=map_writes.equal_range(read);
945 for(id2nodet::iterator id_it=with_same_var.first;
946 id_it!=with_same_var.second; id_it++)
949 instrumenter.message.debug() << id_it->second<<
"<-com->"
951 std::map<event_idt, event_idt>::const_iterator entry=
952 instrumenter.map_vertex_gnode.find(id_it->second);
953 assert(entry!=instrumenter.map_vertex_gnode.end());
962 for(std::set<event_idt>::const_iterator id_it=
963 unknown_write_nodes.begin();
964 id_it!=unknown_write_nodes.end();
968 instrumenter.message.debug() << *id_it<<
"<-com->"
970 std::map<event_idt, event_idt>::const_iterator entry=
971 instrumenter.map_vertex_gnode.find(*id_it);
972 assert(entry!=instrumenter.map_vertex_gnode.end());
982 for(
const auto &w_entry : rw_set.
w_entries)
988 const irep_idt &write = w_entry.second.object;
990 instrumenter.message.debug() <<
"WRITE: " << write <<
messaget::eom;
1004 instrumenter.unique_id++,
1010 egraph[new_write_node](new_write_event);
1012 <<
"new Write " << write <<
" @thread" << (thread) <<
"("
1014 << (
local(write) ?
"local" :
"shared") <<
") #" << new_write_node
1017 if(write==ID_unknown)
1018 unknown_read_nodes.insert(new_write_node);
1022 instrumenter.map_vertex_gnode.insert(
1023 std::pair<event_idt, event_idt>(new_write_node, new_write_gnode));
1026 if(previous!=std::numeric_limits<event_idt>::max())
1028 instrumenter.message.debug() << previous<<
"-po->"<<new_write_node
1037 if(in_pos.find(in)!=in_pos.end())
1039 for(
const auto &node : in_pos[in])
1041 if(
egraph[node.first].thread!=thread)
1043 instrumenter.message.debug() << node.first<<
"-po->"
1053 const std::pair<id2nodet::iterator, id2nodet::iterator>
1054 r_with_same_var=map_reads.equal_range(write);
1055 for(id2nodet::iterator idr_it=r_with_same_var.first;
1056 idr_it!=r_with_same_var.second; idr_it++)
1057 if(
egraph[idr_it->second].thread!=new_write_event.
thread)
1059 instrumenter.message.debug() <<idr_it->second<<
"<-com->"
1061 std::map<event_idt, event_idt>::const_iterator entry=
1062 instrumenter.map_vertex_gnode.find(idr_it->second);
1063 assert(entry!=instrumenter.map_vertex_gnode.end());
1072 const std::pair<id2nodet::iterator, id2nodet::iterator>
1073 w_with_same_var=map_writes.equal_range(write);
1074 for(id2nodet::iterator idw_it=w_with_same_var.first;
1075 idw_it!=w_with_same_var.second; idw_it++)
1076 if(
egraph[idw_it->second].thread!=new_write_event.
thread)
1078 instrumenter.message.debug() << idw_it->second<<
"<-com->"
1080 std::map<event_idt, event_idt>::const_iterator entry=
1081 instrumenter.map_vertex_gnode.find(idw_it->second);
1082 assert(entry!=instrumenter.map_vertex_gnode.end());
1091 for(std::set<event_idt>::const_iterator id_it=
1092 unknown_write_nodes.begin();
1093 id_it!=unknown_write_nodes.end();
1097 instrumenter.message.debug() << *id_it<<
"<-com->"
1099 std::map<event_idt, event_idt>::const_iterator entry=
1100 instrumenter.map_vertex_gnode.find(*id_it);
1101 assert(entry!=instrumenter.map_vertex_gnode.end());
1110 for(std::set<event_idt>::const_iterator id_it=
1111 unknown_read_nodes.begin();
1112 id_it!=unknown_read_nodes.end();
1116 instrumenter.message.debug() << *id_it<<
"<-com->"
1118 std::map<event_idt, event_idt>::const_iterator entry=
1119 instrumenter.map_vertex_gnode.find(*id_it);
1120 assert(entry!=instrumenter.map_vertex_gnode.end());
1130 previous=new_write_node;
1131 previous_gnode=new_write_gnode;
1134 if(previous!=std::numeric_limits<event_idt>::max())
1136 in_pos[i_it].clear();
1137 in_pos[i_it].insert(
nodet(previous, previous_gnode));
1138 updated.insert(i_it);
1143 visit_cfg_skip(i_it);
1147 if(!no_dependencies)
1149 for(
const auto &w_entry : rw_set.
w_entries)
1151 for(
const auto &r_entry : rw_set.
r_entries)
1153 const irep_idt &write = w_entry.second.object;
1154 const irep_idt &read = r_entry.second.object;
1155 instrumenter.message.debug() <<
"dp: Write:"<<write<<
"; Read:"<<read
1159 data_dp.dp_analysis(read_p,
local(read), write_p,
local(write));
1164 for(
const auto &r_entry : rw_set.
r_entries)
1166 for(
const auto &r_entry2 : rw_set.
r_entries)
1168 const irep_idt &read2 = r_entry2.second.object;
1169 const irep_idt &read = r_entry.second.object;
1174 data_dp.dp_analysis(read_p,
local(read), read2_p,
local(read2));
1182 goto_programt::instructionst::iterator i_it,
1190 instrumenter.unique_id++,
1195 egraph[new_fence_node](new_fence_event);
1198 instrumenter.map_vertex_gnode.insert(
1199 std::make_pair(new_fence_node, new_fence_gnode));
1202 if(in_pos.find(in)!=in_pos.end())
1204 for(
const auto &node : in_pos[in])
1206 instrumenter.message.debug() << node.first<<
"-po->"<<new_fence_node
1214 s.insert(
nodet(new_fence_node, new_fence_gnode));
1216 updated.insert(i_it);
1218 in_pos[i_it].clear();
1219 in_pos[i_it].insert(
nodet(new_fence_node, new_fence_gnode));
1220 updated.insert(i_it);
1224 goto_programt::instructionst::iterator i_it)
1226 visit_cfg_propagate(i_it);
1230 goto_programt::instructionst::iterator it,
1234 it->is_set_return_value() || it->is_throw() || it->is_catch() ||
1235 it->is_skip() || it->is_dead() || it->is_start_thread() ||
1236 it->is_end_thread())
1239 if(it->is_atomic_begin() ||
1240 it->is_atomic_end())
1246 if(it->is_function_call())
1262 e_it!=cyc.
end() && ++e_it!=cyc.
end(); ++e_it)
1271 bool thread_found=
false;
1275 for(
const auto &instruction : gf_entry.second.body.instructions)
1277 if(instruction.source_location() == current_location)
1279 current_po = &gf_entry.second.body;
1294 bool exists_n=
false;
1296 for(wmm_grapht::edgest::const_iterator edge_it=pos_cur.begin();
1297 edge_it!=pos_cur.end(); edge_it++)
1299 if(pos_next.find(edge_it->first)!=pos_next.end())
1307 if((++e_it)!=cyc.
end() || !exists_n)
1313 if(i_it->source_location() == current_location)
1316 for(goto_programt::instructionst::iterator same_loc = i_it;
1318 same_loc->source_location() == i_it->source_location();
1332 bool in_cycle=
false;
1335 if(it->source_location() == current_location)
1340 if(it->source_location() == next_location)
1353 if(instruction.is_goto())
1355 for(
const auto &t : instruction.targets)
1357 bool target_in_cycle=
false;
1363 target_in_cycle=
true;
1368 if(!target_in_cycle)
1382 map.insert(std::make_pair(
1384 std::move(one_interleaving)));
1392 bmct bmc(no_option, symbol_table, no_message);
1394 bool is_spurious=bmc.run(this_interleaving);
1408 for(std::set<event_grapht::critical_cyclet>::iterator
1414 std::set<event_grapht::critical_cyclet>::iterator next=it;
1429 for(std::set<event_grapht::critical_cyclet>::iterator it=
1435 std::set<event_grapht::critical_cyclet>::iterator next=it;
1452 const std::set<event_grapht::critical_cyclet> &set,
1455 std::ofstream &output,
1457 std::ofstream &table,
1459 bool hide_internals)
1462 std::map<unsigned, std::set<event_idt> > same_po;
1463 unsigned max_thread=0;
1467 std::map<irep_idt, std::set<event_idt> > same_file;
1470 std::map<std::string, std::string> map_id2var;
1471 std::map<std::string, std::string> map_var2id;
1473 for(std::set<event_grapht::critical_cyclet>::const_iterator it =
1474 set.begin(); it!=set.end(); it++)
1476 #ifdef PRINT_UNSAFES
1479 it->print_dot(
dot, colour++, model);
1480 ref << it->print_name(model, hide_internals) <<
'\n';
1481 output << it->print_output() <<
'\n';
1482 all << it->print_all(model, map_id2var, map_var2id, hide_internals)
1486 for(std::list<event_idt>::const_iterator it_e=it->begin();
1487 it_e!=it->end(); it_e++)
1492 same_po[ev.
thread].insert(*it_e);
1503 dot << ev.
id <<
"[label=\"\\\\lb {" << ev.
id <<
"}";
1505 dot << ev.
thread <<
"\",color=red,shape=box];\n";
1513 for(
unsigned i=0; i<=max_thread; i++)
1514 if(!same_po[i].empty())
1516 dot <<
"{rank=same; thread_" << i
1517 <<
"[shape=plaintext, label=\"thread " << i <<
"\"];";
1518 for(std::set<event_idt>::iterator it=same_po[i].begin();
1519 it!=same_po[i].end(); it++)
1528 for(std::map<
irep_idt, std::set<event_idt> >::const_iterator it=
1530 it!=same_file.end(); it++)
1533 dot <<
" label=\"" << it->first <<
"\";\n";
1534 for(std::set<event_idt>::const_iterator ev_it=it->second.begin();
1535 ev_it!=it->second.end(); ev_it++)
1537 dot <<
" " <<
egraph[*ev_it].id <<
";\n";
1544 table << std::string(80,
'-');
1545 for(std::map<std::string, std::string>::const_iterator
1546 m_it=map_id2var.begin();
1547 m_it!=map_id2var.end();
1550 table <<
"\n| " << m_it->first <<
" : " << m_it->second;
1553 table << std::string(80,
'-');
1561 std::ofstream output;
1563 std::ofstream table;
1565 dot.open(
"cycles.dot");
1566 ref.open(
"ref.txt");
1567 output.open(
"output.txt");
1568 all.open(
"all.txt");
1569 table.open(
"table.txt");
1571 dot <<
"digraph G {\n";
1572 dot <<
"nodesep=1; ranksep=1;\n";
1577 model, hide_internals);
1582 std::ofstream local_dot;
1584 local_dot.open(name.c_str());
1586 local_dot <<
"digraph G {\n";
1587 local_dot <<
"nodesep=1; ranksep=1;\n";
1589 table, model, hide_internals);
1593 dot << i <<
"[label=\"SCC " << i <<
"\",link=\"" <<
"scc_" << i;
1616 std::set<event_grapht::critical_cyclet>());
1617 for(std::vector<std::set<event_idt> >::const_iterator it=
egraph_SCCs.begin();
1623 class pthread_argumentt
1628 const std::set<event_idt> &filter;
1629 std::set<event_grapht::critical_cyclet> &cycles;
1633 const std::set<event_idt> &_filter,
1634 std::set<event_grapht::critical_cyclet> &_cycles)
1635 :instr(_instr), mem(_mem), filter(_filter), cycles(_cycles)
1641 void *collect_cycles_in_thread(
void *arg)
1644 pthread_argumentt *p_arg=
reinterpret_cast<pthread_argumentt*
>(arg);
1647 const std::set<event_idt> &filter=p_arg->filter;
1648 std::set<event_grapht::critical_cyclet> &cycles=p_arg->cycles;
1657 const unsigned number_of_sccs=
num_sccs;
1658 std::set<unsigned> interesting_SCCs;
1661 pthread_t *threads=
new pthread_t[
num_sccs+1];
1664 std::set<event_grapht::critical_cyclet>());
1666 for(std::vector<std::set<unsigned> >::const_iterator it=
egraph_SCCs.begin();
1670 interesting_SCCs.insert(scc);
1673 int rc=pthread_create(&threads[scc++], NULL,
1674 collect_cycles_in_thread, &arg);
1680 for(
unsigned i=0; i<number_of_sccs; i++)
1681 if(interesting_SCCs.find(i)!=interesting_SCCs.end())
1683 int rc=pthread_join(threads[i], NULL);
std::string get_operation() const
source_locationt source_location
const irep_idt & get_statement() const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
std::string::const_iterator begin() const
data_typet::const_iterator const_iterator
event_idt copy_segment(event_idt begin, event_idt end)
const wmm_grapht::edgest & po_out(event_idt n) const
void collect_cycles(std::set< critical_cyclet > &set_of_cycles, memory_modelt model, const std::set< event_idt > &filter)
std::map< unsigned, data_dpt > map_data_dp
void add_com_edge(event_idt a, event_idt b)
void add_po_edge(event_idt a, event_idt b)
void add_po_back_edge(event_idt a, event_idt b)
Base class for all expressions.
const source_locationt & source_location() const
The Boolean constant false.
A collection of goto functions.
std::map< irep_idt, goto_functiont > function_mapt
function_mapt function_map
static irep_idt entry_point()
Get the identifier of the entry point to a goto model.
A goto function, consisting of function body (see body) and parameter identifiers (see parameter_iden...
This class represents an instruction in the GOTO intermediate representation.
bool is_set_return_value() const
std::set< targett > incoming_edges
const exprt & call_function() const
Get the function that is called for FUNCTION_CALL.
bool is_end_thread() const
const codet & get_code() const
Get the code represented by this instruction.
bool is_start_thread() const
bool is_atomic_end() const
bool is_backwards_goto() const
Returns true if the instruction is a backwards branch.
bool is_atomic_begin() const
void clear(goto_program_instruction_typet __type)
Clear the node.
const source_locationt & source_location() const
bool is_function_call() const
goto_program_instruction_typet type() const
What kind of instruction?
A generic container class for the GOTO intermediate representation of one function.
instructionst instructions
The list of instructions in the goto program.
void copy_from(const goto_programt &src)
Copy a full goto program, preserving targets.
instructionst::const_iterator const_targett
std::list< instructiont > instructionst
targett add(instructiont &&instruction)
Adds a given instruction at the end.
static instructiont make_assertion(const exprt &g, const source_locationt &l=source_locationt::nil())
std::size_t SCCs(std::vector< node_indext > &subgraph_nr) const
Computes strongly-connected components of a graph and yields a vector expressing a mapping from nodes...
node_indext add_node(arguments &&... values)
void add_edge(node_indext a, node_indext b)
void visit_cfg_backedge(goto_programt::const_targett targ, goto_programt::const_targett i_it)
strategy: fwd/bwd alternation
void visit_cfg_reference_function(irep_idt id_function)
references the first and last edges of the function
bool contains_shared_array(const irep_idt &function_id, goto_programt::const_targett targ, goto_programt::const_targett i_it, value_setst &value_sets) const
instrumentert & instrumenter
virtual void visit_cfg_function(value_setst &value_sets, memory_modelt model, bool no_dependencies, loop_strategyt duplicate_body, const irep_idt &function_id, std::set< nodet > &ending_vertex)
TODO: move the visitor outside, and inherit.
std::pair< irep_idt, event_idt > id2node_pairt
bool local(const irep_idt &i)
void visit_cfg_fence(goto_programt::instructionst::iterator i_it, const irep_idt &function_id)
void visit_cfg_goto(const irep_idt &function_id, const goto_programt &goto_program, goto_programt::instructionst::iterator i_it, loop_strategyt replicate_body, value_setst &value_sets)
void visit_cfg_function_call(value_setst &value_sets, goto_programt::instructionst::iterator i_it, memory_modelt model, bool no_dependenciess, loop_strategyt duplicate_body)
void visit_cfg_lwfence(goto_programt::instructionst::iterator i_it, const irep_idt &function_id)
void visit_cfg_propagate(goto_programt::instructionst::iterator i_it)
void visit_cfg_assign(value_setst &value_sets, const irep_idt &function_id, goto_programt::instructionst::iterator &i_it, bool no_dependencies)
void visit_cfg(value_setst &value_sets, memory_modelt model, bool no_dependencies, loop_strategyt duplicate_body, const irep_idt &function_id)
void visit_cfg_duplicate(const goto_programt &goto_program, goto_programt::const_targett targ, goto_programt::const_targett i_it)
void visit_cfg_body(const irep_idt &function_id, const goto_programt &goto_program, goto_programt::const_targett i_it, loop_strategyt replicate_body, value_setst &value_sets)
strategy: fwd/bwd alternation
std::pair< event_idt, event_idt > nodet
void visit_cfg_thread() const
void visit_cfg_skip(goto_programt::instructionst::iterator i_it)
void visit_cfg_asm_fence(goto_programt::instructionst::iterator i_it, const irep_idt &function_id)
void print_outputs(memory_modelt model, bool hide_internals)
void collect_cycles_by_SCCs(memory_modelt model)
Note: can be distributed (#define DISTRIBUTED)
std::set< event_grapht::critical_cyclet > set_of_cycles
std::set< irep_idt > var_to_instr
std::vector< std::set< event_idt > > egraph_SCCs
std::multimap< irep_idt, source_locationt > id2loc
bool is_cfg_spurious(const event_grapht::critical_cyclet &cyc)
goto_functionst & goto_functions
std::map< event_idt, event_idt > map_vertex_gnode
std::vector< std::set< event_grapht::critical_cyclet > > set_of_cycles_per_SCC
void add_instr_to_interleaving(goto_programt::instructionst::iterator it, goto_programt &interleaving)
bool local(const irep_idt &id)
is local variable?
unsigned goto2graph_cfg(value_setst &value_sets, memory_modelt model, bool no_dependencies, loop_strategyt duplicate_body)
goes through CFG and build a static abstract event graph overapproximating the read/write relations f...
void print_outputs_local(const std::set< event_grapht::critical_cyclet > &set, std::ofstream &dot, std::ofstream &ref, std::ofstream &output, std::ofstream &all, std::ofstream &table, memory_modelt model, bool hide_internals)
bool get_bool(const irep_idt &name) const
mstreamt & statistics() const
mstreamt & status() const
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
const irep_idt & get_file() const
const irep_idt & get_identifier() const
bool has_prefix(const std::string &s, const std::string &prefix)
void dot(const goto_modelt &src, std::ostream &out)
wmm_grapht::node_indext event_idt
bool is_fence(const goto_programt::instructiont &instruction, const namespacet &ns)
bool is_lwfence(const goto_programt::instructiont &instruction, const namespacet &ns)
Fences for instrumentation.
event_idt alt_copy_segment(wmm_grapht &alt_egraph, event_idt begin, event_idt end)
#define add_all_pos(it, target, source)
#define forall_goto_program_instructions(it, program)
#define Forall_goto_program_instructions(it, program)
dstring_hash irep_id_hash
const std::string & id2string(const irep_idt &d)
Race Detection for Threaded Goto Programs.
#define INITIALIZE_FUNCTION
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.