30 var_mapt::const_iterator it=
var_map.find(
object);
37 const symbolt &symbol=ns.lookup(
object);
44 vars.w_buff0_used=
add(
object, symbol.
base_name,
"$w_buff0_used",
46 vars.w_buff1_used=
add(
object, symbol.
base_name,
"$w_buff1_used",
50 vars.flush_delayed=
add(
object, symbol.
base_name,
"$flush_delayed",
55 vars.read_delayed_var=
64 vars.r_buff0_thds.push_back(
70 vars.r_buff1_thds.push_back(
87 const std::string &suffix,
94 new_symbol.
name=identifier;
113 for(
const auto &vars :
var_map)
129 for(
const auto &
id : vars.second.r_buff0_thds)
132 for(
const auto &
id : vars.second.r_buff1_thds)
141 goto_functionst::function_mapt::iterator
145 throw "weak memory instrumentation needs an entry point";
160 std::string identifier=
id2string(id_lhs);
162 const size_t pos=identifier.find(
"[]");
164 if(
pos!=std::string::npos)
167 identifier.erase(
pos);
172 const exprt symbol=ns.
lookup(identifier).symbol_expr();
177 t->code.add_source_location()=source_location;
178 t->source_location=source_location;
184 catch(
const std::string &s)
218 const std::string identifier=
id2string(write_object);
221 const varst &vars=(*this)(write_object);
249 const varst &vars=(*this)(write_object);
261 target->guard=if_expr;
263 target->source_location=source_location;
282 const unsigned current_thread)
284 const std::string identifier=
id2string(
object);
287 const varst &vars=(*this)(object);
293 original_instruction.
code.
op1());
313 const exprt cond_expr=
317 target->guard=cond_expr;
320 target->code.add_source_location()=source_location;
321 target->source_location=source_location;
344 const unsigned current_thread)
346 const std::string identifier=
id2string(
object);
351 const varst &vars=(*this)(object);
375 const exprt new_value_expr=
377 buff0_used_and_mine_expr,
380 buff1_used_and_mine_expr,
396 buff0_used_and_mine_expr,
403 const exprt buff0_or_buff1_used_and_mine_expr=
404 or_exprt(buff0_used_and_mine_expr, buff1_used_and_mine_expr);
412 buff0_or_buff1_used_and_mine_expr,
418 const exprt buff0_thd_expr=
430 const exprt buff1_thd_expr=
439 buff0_or_buff1_used_and_mine_expr,
450 const unsigned current_thread,
451 const bool tso_pso_rmo)
453 const std::string identifier=
id2string(
object);
459 const varst &vars=(*this)(object);
498 bool instrumented=
false;
504 typedef std::multimap<irep_idt, source_locationt>::iterator m_itt;
505 std::pair<m_itt, m_itt> ran=
cycles_loc.equal_range(
object);
506 for(m_itt ran_it=ran.first; ran_it!=ran.second; ran_it++)
507 if(ran_it->second==source_location)
516 if(tso_pso_rmo || !instrumented)
525 const exprt cond_134_expr=
535 const exprt val_134_expr=lhs;
536 const exprt buff0_used_134_expr=buff0_used_expr;
537 const exprt buff1_used_134_expr=buff1_used_expr;
538 const exprt buff0_134_expr=buff0_expr;
539 const exprt buff1_134_expr=buff1_expr;
540 const exprt buff0_thd_134_expr=buff0_thd_expr;
541 const exprt buff1_thd_134_expr=buff1_thd_expr;
546 const exprt cond_267_expr=
and_exprt(buff0_used_expr, buff0_thd_expr);
547 const exprt val_267_expr=buff0_expr;
550 const exprt buff0_267_expr=buff0_expr;
551 const exprt buff1_267_expr=buff1_expr;
558 const exprt cond_5_expr=
564 const exprt val_5_expr=buff1_expr;
565 const exprt buff0_used_5_expr=buff0_used_expr;
567 const exprt buff0_5_expr=buff0_expr;
568 const exprt buff1_5_expr=buff1_expr;
569 const exprt buff0_thd_5_expr=buff0_thd_expr;
633 buff0_used_5_expr))));
649 buff1_used_5_expr))));
665 buff0_thd_5_expr))));
680 buff1_thd_5_expr))));
693 goto_program, target, source_location, choice1, nondet_bool_expr);
701 const exprt val_1_expr=lhs;
702 const exprt buff0_used_1_expr=buff0_used_expr;
703 const exprt buff1_used_1_expr=buff1_used_expr;
704 const exprt buff0_1_expr=buff0_expr;
705 const exprt buff1_1_expr=buff1_expr;
706 const exprt buff0_thd_1_expr=buff0_thd_expr;
707 const exprt buff1_thd_1_expr=buff1_thd_expr;
712 const exprt cond_267_expr=
713 and_exprt(buff0_used_expr, buff0_thd_expr);
714 const exprt val_267_expr=buff0_expr;
717 const exprt buff0_267_expr=buff0_expr;
718 const exprt buff1_267_expr=buff1_expr;
725 const exprt cond_3_expr=
731 const exprt val_3_expr=
if_exprt(choice0_expr, buff0_expr, lhs);
732 const exprt buff0_used_3_expr=choice0_expr;
734 const exprt buff0_3_expr=buff0_expr;
735 const exprt buff1_3_expr=buff1_expr;
742 const exprt cond_4_expr=
746 const exprt val_4_expr=
754 const exprt buff0_used_4_expr=
756 const exprt buff1_used_4_expr=choice0_expr;
757 const exprt buff0_4_expr=buff0_expr;
758 const exprt buff1_4_expr=buff1_expr;
759 const exprt buff0_thd_4_expr=buff0_thd_expr;
760 const exprt buff1_thd_4_expr=
766 const exprt cond_5_expr=
768 and_exprt(buff0_used_expr, buff1_thd_expr),
770 const exprt val_5_expr=
775 const exprt buff0_used_5_expr=choice0_expr;
777 const exprt buff0_5_expr=buff0_expr;
778 const exprt buff1_5_expr=buff1_expr;
867 buff0_used_3_expr))))));
889 buff1_used_3_expr))))));
911 buff0_thd_3_expr))))));
933 buff1_thd_3_expr))))));
936 catch(
const std::string &s)
954 identifier==
"stdin" ||
955 identifier==
"stdout" ||
956 identifier==
"stderr" ||
957 identifier==
"sys_nerr" ||
1006 typedef std::multimap<irep_idt, source_locationt>::iterator m_itt;
1007 std::pair<m_itt, m_itt> ran=
cycles_loc.equal_range(identifier);
1008 for(m_itt ran_it=ran.first; ran_it!=ran.second; ran_it++)
1009 if(ran_it->second==source_location)
1043 <<
" reads from "<<
id2string(r_it->second.object)
1108 original_instruction.
swap(instruction);
1123 goto_program, i_it, source_location, e_it->second.object);
1127 goto_program, i_it, source_location, e_it->second.object,
1129 (model==
TSO || model==
PSO || model==
RMO));
1142 goto_program, i_it, source_location, r_it->second.object,
1143 e_it->second.object);
1151 e_it->second.object, original_instruction,
1161 r_it->second.object)!=
1169 <<e_it->second.object
1176 r_it->second.object, vars.
type);
1209 r_it->second.object, rhs);
1216 e_it->second.object, original_instruction.
code.
op1());
1233 const exprt cond_expr=
if_exprt(delayed_expr, mem_value_expr,
1234 e_it->second.symbol_expr);
1238 e_it->second.object, cond_expr);
1246 i_it->make_atomic_end();
1247 i_it->source_location=source_location;
1258 else if(
is_fence(instruction, ns) ||
1267 original_instruction.
swap(instruction);
1277 for(std::set<irep_idt>::iterator s_it=
past_writes.begin();
1287 i_it->make_atomic_end();
1288 i_it->source_location=source_location;
const irep_idt & get_statement() const
void add_initialization_code(goto_functionst &goto_functions)
irep_idt function
The function this instruction belongs to.
The type of an expression.
irep_idt name
The unique identifier.
const std::string & id2string(const irep_idt &d)
pointer_typet pointer_type(const typet &subtype)
targett insert_before(const_targett target)
Insertion before the given target.
goto_program_instruction_typet type
What kind of instruction?
bool is_function_call() const
void weak_memory(value_setst &value_sets, const irep_idt &function, memory_modelt model)
instruments the program for the pairs detected through the CFG
const irep_idt & get_identifier() const
#define forall_rw_set_w_entries(it, rw_set)
The null pointer constant.
exprt value
Initial value of symbol.
The trinary if-then-else operator.
function_mapt function_map
void add_initialization(goto_programt &goto_program)
irep_idt choice(const irep_idt &function, const std::string &suffix)
Symbol table entry.This is a symbol in the symbol table, stored in an object of type symbol_tablet...
static mstreamt & eom(mstreamt &m)
bool get_bool(const irep_namet &name) const
std::string unique()
returns a unique id (for fresh variables)
mstreamt & warning() const
bool is_fence(const goto_programt::instructiont &instruction, const namespacet &ns)
This class represents an instruction in the GOTO intermediate representation.
std::set< irep_idt > instrumentations
bool is_end_thread() const
goto_functionst & goto_functions
#define forall_rw_set_r_entries(it, rw_set)
void write(goto_programt &goto_program, goto_programt::targett &t, const source_locationt &source_location, const irep_idt &object, goto_programt::instructiont &original_instruction, const unsigned current_thread)
instruments write
The boolean constant true.
irep_idt read_delayed_var
instructionst::iterator targett
void affected_by_delay(symbol_tablet &symbol_table, value_setst &value_sets, goto_functionst &goto_functions)
analysis over the goto-program which computes in affected_by_delay_set the variables (non necessarily...
virtual bool move(symbolt &symbol, symbolt *&new_symbol) override
Move a symbol into the symbol table.
std::set< irep_idt > past_writes
Operator to dereference a pointer.
#define INITIALIZE_FUNCTION
instructionst instructions
The list of instructions in the goto program.
void flush_read(goto_programt &goto_program, goto_programt::targett &t, const source_locationt &source_location, const irep_idt &write_object)
flushes read (POWER)
shared_bufferst & shared_buffers
std::vector< irep_idt > r_buff1_thds
A side effect that returns a non-deterministically chosen value.
bool has_prefix(const std::string &s, const std::string &prefix)
const varst & operator()(const irep_idt &object)
instruments the variable
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast a generic exprt to a symbol_exprt.
irep_idt add_fresh_var(const irep_idt &object, const irep_idt &base_name, const std::string &suffix, const typet &type)
Operator to return the address of an object.
The boolean constant false.
std::multimap< irep_idt, source_locationt > cycles_loc
irep_idt add(const irep_idt &object, const irep_idt &base_name, const std::string &suffix, const typet &type, bool added_as_instrumentation)
add a new var for instrumenting the input var
std::vector< irep_idt > r_buff0_thds
A generic container class for the GOTO intermediate representation of one function.
A non-fatal assertion, which checks a condition then permits execution to continue.
typet type
Type of symbol.
void nondet_flush(goto_programt &goto_program, goto_programt::targett &t, const source_locationt &source_location, const irep_idt &object, const unsigned current_thread, const bool tso_pso_rmo)
instruments read
static irep_idt entry_point()
source_locationt source_location
The location of the instruction in the source file.
Fences for instrumentation.
bool is_buffered(const namespacet &, const symbol_exprt &, bool is_write)
Base class for all expressions.
irep_idt base_name
Base (non-scoped) name.
symbol_tablet & symbol_table
std::string to_string(const string_constraintt &expr)
Used for debug printing.
#define Forall_goto_functions(it, functions)
const source_locationt & source_location() const
void det_flush(goto_programt &goto_program, goto_programt::targett &t, const source_locationt &source_location, const irep_idt &object, const unsigned current_thread)
flush buffers (instruments fence)
void swap(instructiont &instruction)
Swap two instructions.
std::set< irep_idt > cycles
goto_programt & goto_program
#define Forall_goto_program_instructions(it, program)
Expression to hold a symbol (variable)
class symbol_tablet & symbol_table
std::set< irep_idt > affected_by_delay_set
bool is_start_thread() const
bool is_buffered_in_general(const namespacet &, const symbol_exprt &, bool is_write)
void delay_read(goto_programt &goto_program, goto_programt::targett &t, const source_locationt &source_location, const irep_idt &read_object, const irep_idt &write_object)
delays a read (POWER)
void assignment(goto_programt &goto_program, goto_programt::targett &t, const source_locationt &source_location, const irep_idt &id_lhs, const exprt &rhs)
add an assignment in the goto-program
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See namespace_baset::lookup().
const code_function_callt & to_code_function_call(const codet &code)
bool is_lwfence(const goto_programt::instructiont &instruction, const namespacet &ns)
Race Detection for Threaded Goto Programs.