27 return "$fresh#"+std::to_string(
uniq++);
34 var_mapt::const_iterator it=
var_map.find(
object);
45 vars.w_buff0 =
add(symbol,
"$w_buff0", symbol.
type);
46 vars.w_buff1 =
add(symbol,
"$w_buff1", symbol.
type);
51 vars.mem_tmp =
add(symbol,
"$mem_tmp", symbol.
type);
55 vars.read_delayed_var =
74 const std::string &suffix,
93 return new_symbol.
name;
106 assignment(goto_program, t, source_location,
vars.second.w_buff0_used,
108 assignment(goto_program, t, source_location,
vars.second.w_buff1_used,
110 assignment(goto_program, t, source_location,
vars.second.flush_delayed,
112 assignment(goto_program, t, source_location,
vars.second.read_delayed,
114 assignment(goto_program, t, source_location,
vars.second.read_delayed_var,
117 for(
const auto &
id :
vars.second.r_buff0_thds)
120 for(
const auto &
id :
vars.second.r_buff1_thds)
129 goto_functionst::function_mapt::iterator
133 throw "weak memory instrumentation needs an entry point";
150 const size_t pos=identifier.find(
"[]");
152 if(
pos!=std::string::npos)
155 identifier.erase(
pos);
160 const exprt symbol=ns.
lookup(identifier).symbol_expr();
169 catch(
const std::string &s)
187 assignment(goto_program, target, source_location,
vars.read_delayed,
189 assignment(goto_program, target, source_location,
vars.read_delayed_var,
220 vars.read_delayed_var,
246 target->guard.source_location()=source_location;
247 target->source_location=source_location;
251 assignment(goto_program, target, source_location,
vars.read_delayed,
259 (
void)source_location;
271 const unsigned current_thread)
273 const std::string identifier=
id2string(
object);
305 const exprt cond_expr=
322 vars.r_buff0_thds[current_thread],
332 const unsigned current_thread)
334 const std::string identifier=
id2string(
object);
413 vars.r_buff0_thds[current_thread],
425 vars.r_buff1_thds[current_thread],
439 const unsigned current_thread,
442 const std::string identifier=
id2string(
object);
483 goto_program, target, source_location,
vars.flush_delayed,
delay_expr);
484 assignment(goto_program, target, source_location,
vars.mem_tmp, lhs);
494 typedef std::multimap<irep_idt, source_locationt>::iterator
m_itt;
497 if(
ran_it->second==source_location)
645 vars.r_buff0_thds[current_thread],
885 vars.r_buff0_thds[current_thread],
907 vars.r_buff1_thds[current_thread],
926 catch(
const std::string &s)
944 identifier ==
CPROVER_PREFIX "alloc_size" || identifier ==
"stdin" ||
945 identifier ==
"stdout" || identifier ==
"stderr" ||
946 identifier ==
"sys_nerr" || identifier.
starts_with(
"__unbuffered_") ||
993 typedef std::multimap<irep_idt, source_locationt>::iterator
m_itt;
994 std::pair<m_itt, m_itt>
ran=
cycles_loc.equal_range(identifier);
996 if(
ran_it->second==source_location)
1123 goto_program,
i_it, source_location,
r_entry.second.object);
1133 (model ==
TSO || model ==
PSO || model ==
RMO));
1145 ns,
r_entry.second.symbol_expr,
true))
1184 <<
"writer " <<
w_entry.second.object <<
" reads "
1193 vars.read_delayed_var,
1265 goto_program,
i_it, source_location,
1287 (instruction.
code().get_bool(
"WRfence") ||
1288 instruction.
code().get_bool(
"WWfence") ||
1289 instruction.
code().get_bool(
"RWfence") ||
1290 instruction.
code().get_bool(
"RRfence"))))
1306 goto_program,
i_it, source_location, *
s_it,
pointer_typet pointer_type(const typet &subtype)
Operator to return the address of an object.
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Operator to dereference a pointer.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
bool starts_with(const char *s) const
equivalent of as_string().starts_with(s)
Base class for all expressions.
const source_locationt & source_location() const
The Boolean constant false.
A collection of goto functions.
function_mapt function_map
static irep_idt entry_point()
Get the identifier of the entry point to a goto model.
This class represents an instruction in the GOTO intermediate representation.
const goto_instruction_codet & code() const
Get the code represented by this instruction.
bool is_end_thread() const
bool is_start_thread() const
const exprt & call_function() const
Get the function that is called for FUNCTION_CALL.
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.
instructionst::iterator targett
static instructiont make_atomic_end(const source_locationt &l=source_locationt::nil())
static instructiont make_assignment(const code_assignt &_code, const source_locationt &l=source_locationt::nil())
Create an assignment instruction.
static instructiont make_skip(const source_locationt &l=source_locationt::nil())
static instructiont make_atomic_begin(const source_locationt &l=source_locationt::nil())
static instructiont make_assertion(const exprt &g, const source_locationt &l=source_locationt::nil())
targett insert_before(const_targett target)
Insertion before the instruction pointed-to by the given instruction iterator target.
The trinary if-then-else operator.
message_handlert & get_message_handler()
mstreamt & warning() const
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
The null pointer constant.
shared_bufferst & shared_buffers
symbol_table_baset & symbol_table
void weak_memory(value_setst &value_sets, const irep_idt &function_id, memory_modelt model)
instruments the program for the pairs detected through the CFG
std::set< irep_idt > past_writes
goto_functionst & goto_functions
std::multimap< irep_idt, source_locationt > cycles_loc
const varst & operator()(const irep_idt &object)
instruments the variable
void nondet_flush(const irep_idt &function_id, 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
std::string unique()
returns a unique id (for fresh variables)
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
void affected_by_delay(value_setst &value_sets, goto_functionst &goto_functions)
analysis over the goto-program which computes in affected_by_delay_set the variables (non necessarily...
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)
irep_idt add_fresh_var(const symbolt &object, const std::string &suffix, const typet &type)
void add_initialization(goto_programt &goto_program)
bool is_buffered_in_general(const symbol_exprt &, bool is_write)
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
irep_idt add(const symbolt &object, const std::string &suffix, const typet &type, bool added_as_instrumentation)
add a new var for instrumenting the input var
std::set< irep_idt > affected_by_delay_set
class symbol_table_baset & symbol_table
std::set< irep_idt > cycles
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 flush_read(goto_programt &goto_program, goto_programt::targett &t, const source_locationt &source_location, const irep_idt &write_object)
flushes read (POWER)
irep_idt choice(const irep_idt &function_id, const std::string &suffix)
void add_initialization_code(goto_functionst &goto_functions)
bool is_buffered(const namespacet &, const symbol_exprt &, bool is_write)
std::set< irep_idt > instrumentations
A side_effect_exprt that returns a non-deterministically chosen value.
Expression to hold a symbol (variable)
const irep_idt & get_identifier() const
typet type
Type of symbol.
irep_idt name
The unique identifier.
exprt value
Initial value of symbol.
The Boolean constant true.
The type of an expression, extends irept.
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.
symbolt & get_fresh_aux_symbol(const typet &type, const std::string &name_prefix, const std::string &basename_prefix, const source_locationt &source_location, const irep_idt &symbol_mode, const namespacet &ns, symbol_table_baset &symbol_table)
Installs a fresh-named symbol with respect to the given namespace ns with the requested name pattern ...
Fresh auxiliary symbol creation.
#define Forall_goto_program_instructions(it, program)
const std::string & id2string(const irep_idt &d)
API to expression classes for Pointers.
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.