Go to the documentation of this file.
44 auto p = util_make_unique<rd_range_domaint>(
bv_container);
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)
104 "ai has type reaching_definitions_analysist");
112 else if(from->is_start_thread())
115 else if(from->is_function_call())
118 else if(from->is_end_function())
121 else if(from->is_assign())
124 else if(from->is_decl())
129 if(to->is_function_call())
137 const bool is_must_alias=rw_set.
get_w_set().size()==1;
141 const irep_idt &identifier=it->first;
144 if(ns.
lookup(identifier, symbol_ptr))
146 assert(symbol_ptr!=0);
154 for(
const auto &range : ranges)
155 kill(identifier, range.first, range.second);
170 valuest::iterator entry=
values.find(identifier);
183 for(valuest::iterator it=
values.begin();
187 const irep_idt &identifier=it->first;
189 if(!ns.
lookup(identifier).is_shared() &&
194 valuest::iterator next=it;
214 if(function_from != function_to)
216 for(valuest::iterator it=
values.begin();
220 const irep_idt &identifier=it->first;
224 if((ns.
lookup(identifier, sym) ||
230 valuest::iterator next=it;
243 for(
const auto ¶m : code_type.
parameters())
245 const irep_idt &identifier=param.get_identifier();
247 if(identifier.
empty())
251 if(param_bits.has_value())
254 gen(from, identifier, 0, -1);
281 for(
const auto &new_value : new_values)
283 const irep_idt &identifier=new_value.first;
286 (!ns.
lookup(identifier).is_shared() &&
289 for(
const auto &
id : new_value.second)
296 for(
const auto &
id : new_value.second)
305 for(
const auto ¶m : code_type.
parameters())
307 const irep_idt &identifier=param.get_identifier();
309 if(identifier.
empty())
312 valuest::iterator entry=
values.find(identifier);
342 goto_rw(function_to, to, rw_set);
343 const bool is_must_alias=rw_set.
get_w_set().size()==1;
347 const irep_idt &identifier=it->first;
350 if(ns.
lookup(identifier, symbol_ptr))
355 "Symbol is in symbol table");
363 for(
const auto &range : ranges)
364 kill(identifier, range.first, range.second);
366 for(
const auto &range : ranges)
367 gen(from, identifier, range.first, range.second);
376 assert(range_start>=0);
384 assert(range_end>range_start);
386 valuest::iterator entry=
values.find(identifier);
390 bool clear_export_cache=
false;
393 for(values_innert::iterator
394 it=entry->second.begin();
395 it!=entry->second.end();
409 clear_export_cache=
true;
411 entry->second.erase(it++);
415 clear_export_cache=
true;
421 entry->second.erase(it++);
426 clear_export_cache=
true;
437 entry->second.erase(it++);
441 clear_export_cache=
true;
447 entry->second.erase(it++);
451 if(clear_export_cache)
454 values_innert::iterator it=entry->second.begin();
455 for(
const auto &
id : new_values)
457 while(it!=entry->second.end() && *it<
id)
459 if(it==entry->second.end() ||
id<*it)
461 entry->second.insert(it,
id);
463 else if(it!=entry->second.end())
475 assert(range_start>=0);
478 valuest::iterator entry=
values.find(identifier);
482 XXX export_cache_available=
false;
487 for(rangest::iterator it=ranges.begin();
490 if(it->second.first!=-1 &&
491 it->second.first <= range_start)
493 else if(it->first >= range_start)
499 it->second.first=range_start;
516 if(range_start==0 && range_end==0)
519 assert(range_start>=0);
522 assert(range_end>range_start || range_end==-1);
538 std::pair<valuest::iterator, bool> entry=
540 rangest &ranges=entry.first->second;
544 for(rangest::iterator it=ranges.begin();
548 if(it->second.second!=from ||
549 (it->second.first!=-1 && it->second.first <= range_start) ||
550 (range_end!=-1 && it->first >= range_end))
552 else if(it->first > range_start)
555 merged_range_end=std::max(range_end, it->second.first);
558 else if(it->second.first==-1 ||
560 it->second.first >= range_end))
567 it->second.first=range_end;
573 ranges.insert(std::make_pair(
575 std::make_pair(merged_range_end, from)));
583 out <<
"Reaching definitions:\n";
591 for(
const auto &value :
values)
593 const irep_idt &identifier=value.first;
597 out <<
" " << identifier <<
"[";
599 for(ranges_at_loct::const_iterator itl=ranges.begin();
602 for(rangest::const_iterator itr=itl->second.begin();
603 itr!=itl->second.end();
606 if(itr!=itl->second.begin() ||
610 out << itr->first <<
":" << itr->second;
611 out <<
"@" << itl->first->location_number;
628 ranges_at_loct::iterator itr=it->second.begin();
629 for(
const auto &o : ito->second)
631 while(itr!=it->second.end() && itr->first<o.first)
633 if(itr==it->second.end() || o.first<itr->first)
635 it->second.insert(o);
638 else if(itr!=it->second.end())
640 assert(itr->first==o.first);
642 for(
const auto &o_range : o.second)
643 more=
gen(itr->second, o_range.first, o_range.second) ||
650 values_innert::iterator itr=dest.begin();
651 for(
const auto &
id : other)
653 while(itr!=dest.end() && *itr<
id)
655 if(itr==dest.end() ||
id<*itr)
657 dest.insert(itr,
id);
660 else if(itr!=dest.end())
680 valuest::iterator it=
values.begin();
681 for(
const auto &value : other.
values)
683 while(it!=
values.end() && it->first<value.first)
685 if(it==
values.end() || value.first<it->first)
692 assert(it->first==value.first);
724 valuest::iterator it=
values.begin();
725 for(
const auto &value : other.
values)
727 const irep_idt &identifier=value.first;
729 if(!ns.
lookup(identifier).is_shared()
733 while(it!=
values.end() && it->first<value.first)
735 if(it==
values.end() || value.first<it->first)
742 assert(it->first==value.first);
764 export_cachet::const_iterator entry=
export_cache.find(identifier);
769 return entry->second;
775 auto value_sets_=util_make_unique<value_set_analysis_fit>(
ns);
776 (*value_sets_)(goto_functions);
779 is_threaded=util_make_unique<is_threadedt>(goto_functions);
781 is_dirty=util_make_unique<dirtyt>(goto_functions);
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
valuest values
It is an ordered map from program variable names to IDs of reaching_definitiont instances stored in m...
Variables whose address is taken.
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...
reaching_definitions_analysist(const namespacet &_ns)
#define CHECK_RETURN(CONDITION)
value_setst & get_value_sets() const
ai_domain_baset::locationt definition_at
The iterator to the GOTO instruction where the variable has been written to.
void transform_assign(const namespacet &ns, locationt from, const irep_idt &function_to, locationt to, reaching_definitions_analysist &rd)
static void goto_rw(const irep_idt &function, goto_programt::const_targett target, const code_assignt &assign, rw_range_sett &rw_set)
std::map< locationt, rangest > ranges_at_loct
const is_threadedt & get_is_threaded() 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::set< std::size_t > values_innert
tvt has_values
This (three value logic) flag determines, whether the instance represents top, bottom,...
bool merge(const rd_range_domaint &other, locationt from, locationt to)
Implements the join operation of two instances *this and other.
sparse_bitvector_analysist< reaching_definitiont > *const bv_container
It points to the actual reaching definitions data of individual program variables.
Expression to hold a symbol (variable)
range_spect bit_begin
The two integers below define a range of bits (i.e.
const ranges_at_loct & get(const irep_idt &identifier) const
range_spect to_range_spect(const mp_integer &size)
std::size_t add(const V &value)
void transform_function_call(const namespacet &ns, const irep_idt &function_from, locationt from, const irep_idt &function_to, reaching_definitions_analysist &rd)
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
std::unique_ptr< T > util_make_unique(Ts &&... ts)
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
codet representation of a function call statement.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
std::unique_ptr< is_threadedt > is_threaded
irep_idt identifier
The name of the variable which was defined.
#define PRECONDITION(CONDITION)
void transform(const irep_idt &function_from, locationt from, const irep_idt &function_to, locationt to, ai_baset &ai, const namespacet &ns) final override
Computes an instance obtained from the instance *this by transformation over a GOTO instruction refer...
const code_deadt & to_code_dead(const codet &code)
const irep_idt & get_identifier() const
optionalt< mp_integer > pointer_offset_bits(const typet &type, const namespacet &ns)
Over-approximate Concurrency for Threaded Goto Programs.
Because the class is inherited from ai_domain_baset, its instance represents an element of a domain o...
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
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...
const code_function_callt & to_code_function_call(const codet &code)
const char * to_string() const
Range-based reaching definitions analysis (following Field- Sensitive Program Dependence Analysis,...
Value Set Propagation (flow insensitive)
const parameterst & parameters() const
std::multimap< range_spect, range_spect > rangest
bool merge_inner(values_innert &dest, const values_innert &other)
sparse_bitvector_analysist< reaching_definitiont > *const bv_container
#define forall_rw_range_set_w_objects(it, rw_set)
void transform_dead(const namespacet &ns, locationt from)
Computes an instance obtained from a *this by transformation over DEAD v GOTO instruction.
virtual ~reaching_definitions_analysist()
virtual void initialize(const irep_idt &function_id, const goto_programt &goto_program)
Initialize all the abstract states for a single function.
A collection of goto functions.
goto_programt::const_targett locationt
std::unique_ptr< statet > make(locationt) const override
void transform_start_thread(const namespacet &ns, reaching_definitions_analysist &rd)
const dirtyt & get_is_dirty() const
bool merge_shared(const rd_range_domaint &other, locationt from, locationt to, const namespacet &ns)
Base class for concurrency-aware abstract interpretation.
This is the basic interface of the abstract interpreter with default implementations of the core func...
rd_range_domain_factoryt(sparse_bitvector_analysist< reaching_definitiont > *_bv_container)
#define INVARIANT_STRUCTURED(CONDITION, TYPENAME,...)
void initialize(const goto_functionst &goto_functions) override
Initialize all the abstract states for a whole program.
ai_domain_baset::locationt locationt
export_cachet export_cache
It is a helper data structure.
void kill_inf(const irep_idt &identifier, const range_spect &range_start)
Identifies a GOTO instruction where a given variable is defined (i.e.
const irep_idt & get_identifier() const
void kill(const irep_idt &identifier, const range_spect &range_start, const range_spect &range_end)
void output(std::ostream &out, const ai_baset &, const namespacet &) const final override
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)
std::unique_ptr< dirtyt > is_dirty
This ensures that all domains are constructed with the appropriate pointer back to the analysis engin...
void clear_cache(const irep_idt &identifier) const
std::map< irep_idt, values_innert > valuest
virtual statet & get_state(locationt l)
const V & get(const std::size_t value_index) const
std::unique_ptr< value_setst > value_sets
const objectst & get_w_set() const
const range_domaint & get_ranges(objectst::const_iterator it) const