46 return std::unique_ptr<statet>(p.release());
75 valuest::const_iterator v_entry=
values.find(identifier);
76 if(v_entry==
values.end() ||
77 v_entry->second.empty())
82 for(
const auto &
id : v_entry->second)
99 locationt from{trace_from->current_location()};
100 locationt to{trace_to->current_location()};
107 "ai has type reaching_definitions_analysist");
115 else if(from->is_start_thread())
118 else if(from->is_function_call())
121 else if(from->is_end_function())
124 else if(from->is_assign())
127 else if(from->is_decl())
130 else if(from->is_other())
140 const irep_idt &identifier = from->dead_symbol().get_identifier();
142 valuest::iterator entry=
values.find(identifier);
155 for(valuest::iterator it=
values.begin();
159 const irep_idt &identifier=it->first;
161 if(!ns.
lookup(identifier).is_shared() &&
166 valuest::iterator next=it;
187 for(valuest::iterator it=
values.begin();
191 const irep_idt &identifier=it->first;
195 if((ns.
lookup(identifier, sym) ||
201 valuest::iterator next=it;
213 for(
const auto ¶m : code_type.
parameters())
215 const irep_idt &identifier=param.get_identifier();
217 if(identifier.
empty())
221 if(param_bits.has_value())
236 if(from->call_lhs().is_not_nil())
256 for(
const auto &new_value : new_values)
258 const irep_idt &identifier=new_value.first;
261 (!ns.
lookup(identifier).is_shared() &&
264 for(
const auto &
id : new_value.second)
271 for(
const auto &
id : new_value.second)
280 for(
const auto ¶m : code_type.
parameters())
282 const irep_idt &identifier=param.get_identifier();
284 if(identifier.
empty())
287 valuest::iterator entry=
values.find(identifier);
297 if(call->call_lhs().is_not_nil())
311 goto_rw(function_to, to, rw_set);
312 const bool is_must_alias=rw_set.
get_w_set().size()==1;
314 for(
const auto &written_object_entry : rw_set.
get_w_set())
316 const irep_idt &identifier = written_object_entry.first;
319 if(ns.
lookup(identifier, symbol_ptr))
324 "Symbol is in symbol table");
327 rw_set.
get_ranges(written_object_entry.second);
333 for(
const auto &range : ranges)
334 kill(identifier, range.first, range.second);
336 for(
const auto &range : ranges)
337 gen(from, identifier, range.first, range.second);
356 valuest::iterator entry=
values.find(identifier);
360 bool clear_export_cache=
false;
363 for(values_innert::iterator
364 it=entry->second.begin();
365 it!=entry->second.end();
380 clear_export_cache=
true;
382 entry->second.erase(it++);
386 clear_export_cache=
true;
392 entry->second.erase(it++);
396 clear_export_cache=
true;
407 entry->second.erase(it++);
411 clear_export_cache=
true;
417 entry->second.erase(it++);
421 if(clear_export_cache)
424 values_innert::iterator it=entry->second.begin();
425 for(
const auto &
id : new_values)
427 while(it!=entry->second.end() && *it<id)
429 if(it==entry->second.end() ||
id<*it)
431 entry->second.insert(it,
id);
433 else if(it!=entry->second.end())
448 valuest::iterator entry=
values.find(identifier);
452 XXX export_cache_available=
false;
457 for(rangest::iterator it=ranges.begin();
460 if(it->second.first!=-1 &&
461 it->second.first <= range_start)
463 else if(it->first >= range_start)
469 it->second.first=range_start;
501 std::pair<valuest::iterator, bool> entry=
503 rangest &ranges=entry.first->second;
507 for(rangest::iterator it=ranges.begin();
511 if(it->second.second!=from ||
512 (it->second.first!=-1 && it->second.first <= range_start) ||
513 (range_end!=-1 && it->first >= range_end))
515 else if(it->first > range_start)
518 merged_range_end=std::max(range_end, it->second.first);
521 else if(it->second.first==-1 ||
523 it->second.first >= range_end))
530 it->second.first=range_end;
536 ranges.insert(std::make_pair(
538 std::make_pair(merged_range_end, from)));
546 out <<
"Reaching definitions:\n";
554 for(
const auto &value :
values)
556 const irep_idt &identifier=value.first;
560 out <<
" " << identifier <<
"[";
562 for(ranges_at_loct::const_iterator itl=ranges.begin();
565 for(rangest::const_iterator itr=itl->second.begin();
566 itr!=itl->second.end();
569 if(itr!=itl->second.begin() ||
573 out << itr->first <<
":" << itr->second;
574 out <<
"@" << itl->first->location_number;
591 ranges_at_loct::iterator itr=it->second.begin();
592 for(
const auto &o : ito->second)
594 while(itr!=it->second.end() && itr->first<o.first)
596 if(itr==it->second.end() || o.first<itr->first)
598 it->second.insert(o);
601 else if(itr!=it->second.end())
603 assert(itr->first==o.first);
605 for(
const auto &o_range : o.second)
606 more=
gen(itr->second, o_range.first, o_range.second) ||
613 values_innert::iterator itr=dest.begin();
614 for(
const auto &
id : other)
616 while(itr!=dest.end() && *itr<id)
618 if(itr==dest.end() ||
id<*itr)
620 dest.insert(itr,
id);
623 else if(itr!=dest.end())
642 valuest::iterator it=
values.begin();
643 for(
const auto &value : other.
values)
645 while(it!=
values.end() && it->first<value.first)
647 if(it==
values.end() || value.first<it->first)
686 valuest::iterator it=
values.begin();
687 for(
const auto &value : other.
values)
689 const irep_idt &identifier=value.first;
691 if(!ns.
lookup(identifier).is_shared()
695 while(it!=
values.end() && it->first<value.first)
697 if(it==
values.end() || value.first<it->first)
726 export_cachet::const_iterator entry=
export_cache.find(identifier);
731 return entry->second;
738 (*value_sets_)(goto_functions);
Generic exception types primarily designed for use with invariants.
This is the basic interface of the abstract interpreter with default implementations of the core func...
virtual void initialize(const irep_idt &function_id, const goto_programt &goto_program)
Initialize all the abstract states for a single function.
ai_history_baset::trace_ptrt trace_ptrt
goto_programt::const_targett locationt
ai_domain_factory_baset::locationt locationt
const parameterst & parameters() const
Base class for concurrency-aware abstract interpretation.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
A collection of goto functions.
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().
Data type to describe upper and lower bounds of the range of bits that a read or write access may aff...
static range_spect unknown()
static range_spect to_range_spect(const mp_integer &size)
This ensures that all domains are constructed with the appropriate pointer back to the analysis engin...
std::unique_ptr< statet > make(locationt) const override
sparse_bitvector_analysist< reaching_definitiont > *const bv_container
rd_range_domain_factoryt(sparse_bitvector_analysist< reaching_definitiont > *_bv_container)
Because the class is inherited from ai_domain_baset, its instance represents an element of a domain o...
void populate_cache(const irep_idt &identifier) const
Given the passed variable name identifier it collects data from bv_container for each ID in values[id...
export_cachet export_cache
It is a helper data structure.
void output(std::ostream &out, const ai_baset &, const namespacet &) const final override
void kill_inf(const irep_idt &identifier, const range_spect &range_start)
void transform_dead(const namespacet &ns, locationt from)
Computes an instance obtained from a *this by transformation over DEAD v GOTO instruction.
void transform_start_thread(const namespacet &ns, reaching_definitions_analysist &rd)
const ranges_at_loct & get(const irep_idt &identifier) const
void clear_cache(const irep_idt &identifier) const
sparse_bitvector_analysist< reaching_definitiont > *const bv_container
It points to the actual reaching definitions data of individual program variables.
void transform_function_call(const namespacet &ns, const irep_idt &function_from, locationt from, const irep_idt &function_to, reaching_definitions_analysist &rd)
bool merge(const rd_range_domaint &other, trace_ptrt from, trace_ptrt to)
Implements the "join" operation of two instances *this and other.
void transform_end_function(const namespacet &ns, const irep_idt &function_from, locationt from, const irep_idt &function_to, locationt to, reaching_definitions_analysist &rd)
void transform_assign(const namespacet &ns, locationt from, const irep_idt &function_to, locationt to, reaching_definitions_analysist &rd)
bool merge_inner(values_innert &dest, const values_innert &other)
std::multimap< range_spect, range_spect > rangest
bool gen(locationt from, const irep_idt &identifier, const range_spect &range_start, const range_spect &range_end)
A utility function which updates internal data structures by inserting a new reaching definition reco...
void kill(const irep_idt &identifier, const range_spect &range_start, const range_spect &range_end)
std::map< locationt, rangest, goto_programt::target_less_than > ranges_at_loct
tvt has_values
This (three value logic) flag determines, whether the instance represents top, bottom,...
void transform(const irep_idt &function_from, trace_ptrt trace_from, const irep_idt &function_to, trace_ptrt trace_to, ai_baset &ai, const namespacet &ns) final override
Computes an instance obtained from the instance *this by transformation over a GOTO instruction refer...
std::map< irep_idt, values_innert > valuest
valuest values
It is an ordered map from program variable names to IDs of reaching_definitiont instances stored in m...
bool merge_shared(const rd_range_domaint &other, locationt from, locationt to, const namespacet &ns)
std::set< std::size_t > values_innert
value_setst & get_value_sets() const
virtual ~reaching_definitions_analysist()
std::unique_ptr< is_threadedt > is_threaded
reaching_definitions_analysist(const namespacet &_ns)
const dirtyt & get_is_dirty() const
const is_threadedt & get_is_threaded() const
std::unique_ptr< dirtyt > is_dirty
std::unique_ptr< value_setst > value_sets
void initialize(const goto_functionst &goto_functions) override
Initialize all the abstract states for a whole program.
const objectst & get_w_set() const
const range_domaint & get_ranges(const std::unique_ptr< range_domain_baset > &ranges) const
An instance of this class provides an assignment of unique numeric ID to each inserted reaching_defin...
const V & get(const std::size_t value_index) const
std::vector< typename inner_mapt::const_iterator > values
It is a map from an ID to the corresponding reaching_definitiont instance inside the map value_map.
std::size_t add(const V &value)
Expression to hold a symbol (variable)
const irep_idt & get_identifier() const
const char * to_string() const
Variables whose address is taken.
static void goto_rw(const irep_idt &function, goto_programt::const_targett target, const exprt &lhs, const exprt &function_expr, const exprt::operandst &arguments, rw_range_sett &rw_set)
Over-approximate Concurrency for Threaded Goto Programs.
std::unique_ptr< T > util_make_unique(Ts &&... ts)
optionalt< mp_integer > pointer_offset_bits(const typet &type, const namespacet &ns)
Range-based reaching definitions analysis (following Field- Sensitive Program Dependence Analysis,...
#define INVARIANT_STRUCTURED(CONDITION, TYPENAME,...)
#define CHECK_RETURN(CONDITION)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
#define PRECONDITION(CONDITION)
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
Identifies a GOTO instruction where a given variable is defined (i.e.
range_spect bit_begin
The two integers below define a range of bits (i.e.
ai_domain_baset::locationt definition_at
The iterator to the GOTO instruction where the variable has been written to.
irep_idt identifier
The name of the variable which was defined.
Value Set Propagation (flow insensitive)