42 valuest::const_iterator v_entry=
values.find(identifier);
43 if(v_entry==
values.end() ||
44 v_entry->second.empty())
49 for(
const auto &
id : v_entry->second)
69 "ai has type reaching_definitions_analysist");
77 else if(from->is_start_thread())
80 else if(from->is_function_call())
83 else if(from->is_end_function())
86 else if(from->is_assign())
89 else if(from->is_decl())
94 if(to->is_function_call())
102 const bool is_must_alias=rw_set.get_w_set().size()==1;
106 const irep_idt &identifier=it->first;
109 if(ns.
lookup(identifier, symbol_ptr))
111 assert(symbol_ptr!=0);
119 for(
const auto &range : ranges)
120 kill(identifier, range.first, range.second);
134 valuest::iterator entry=
values.find(identifier);
147 for(valuest::iterator it=
values.begin();
151 const irep_idt &identifier=it->first;
153 if(!ns.
lookup(identifier).is_shared() &&
158 valuest::iterator next=it;
177 if(from->function != to->function)
179 for(valuest::iterator it=
values.begin();
183 const irep_idt &identifier=it->first;
187 if((ns.
lookup(identifier, sym) ||
193 valuest::iterator next=it;
206 for(
const auto ¶m : code_type.parameters())
208 const irep_idt &identifier=param.get_identifier();
210 if(identifier.
empty())
215 gen(from, identifier, 0, size);
242 for(
const auto &new_value : new_values)
244 const irep_idt &identifier=new_value.first;
247 (!ns.
lookup(identifier).is_shared() &&
250 for(
const auto &
id : new_value.second)
257 for(
const auto &
id : new_value.second)
267 for(
const auto ¶m : code_type.
parameters())
269 const irep_idt &identifier=param.get_identifier();
271 if(identifier.
empty())
274 valuest::iterator entry=
values.find(identifier);
304 const bool is_must_alias=rw_set.get_w_set().size()==1;
308 const irep_idt &identifier=it->first;
311 if(ns.
lookup(identifier, symbol_ptr))
316 "Symbol is in symbol table");
324 for(
const auto &range : ranges)
325 kill(identifier, range.first, range.second);
327 for(
const auto &range : ranges)
328 gen(from, identifier, range.first, range.second);
337 assert(range_start>=0);
345 assert(range_end>range_start);
347 valuest::iterator entry=
values.find(identifier);
351 bool clear_export_cache=
false;
354 for(values_innert::iterator
355 it=entry->second.begin();
356 it!=entry->second.end();
370 clear_export_cache=
true;
372 entry->second.erase(it++);
376 clear_export_cache=
true;
382 entry->second.erase(it++);
387 clear_export_cache=
true;
398 entry->second.erase(it++);
402 clear_export_cache=
true;
408 entry->second.erase(it++);
412 if(clear_export_cache)
415 values_innert::iterator it=entry->second.begin();
416 for(
const auto &
id : new_values)
418 while(it!=entry->second.end() && *it<id)
420 if(it==entry->second.end() ||
id<*it)
422 entry->second.insert(it,
id);
424 else if(it!=entry->second.end())
436 assert(range_start>=0);
439 valuest::iterator entry=
values.find(identifier);
443 XXX export_cache_available=
false;
448 for(rangest::iterator it=ranges.begin();
451 if(it->second.first!=-1 &&
452 it->second.first <= range_start)
454 else if(it->first >= range_start)
460 it->second.first=range_start;
473 if(range_start==0 && range_end==0)
476 assert(range_start>=0);
479 assert(range_end>range_start || range_end==-1);
495 std::pair<valuest::iterator, bool> entry=
497 rangest &ranges=entry.first->second;
501 for(rangest::iterator it=ranges.begin();
505 if(it->second.second!=from ||
506 (it->second.first!=-1 && it->second.first <= range_start) ||
507 (range_end!=-1 && it->first >= range_end))
509 else if(it->first > range_start)
512 merged_range_end=std::max(range_end, it->second.first);
515 else if(it->second.first==-1 ||
517 it->second.first >= range_end))
524 it->second.first=range_end;
530 ranges.insert(std::make_pair(
532 std::make_pair(merged_range_end, from)));
540 out <<
"Reaching definitions:\n";
548 for(
const auto &value :
values)
550 const irep_idt &identifier=value.first;
554 out <<
" " << identifier <<
"[";
556 for(ranges_at_loct::const_iterator itl=ranges.begin();
559 for(rangest::const_iterator itr=itl->second.begin();
560 itr!=itl->second.end();
563 if(itr!=itl->second.begin() ||
567 out << itr->first <<
":" << itr->second;
568 out <<
"@" << itl->first->location_number;
585 ranges_at_loct::iterator itr=it->second.begin();
586 for(
const auto &o : ito->second)
588 while(itr!=it->second.end() && itr->first<o.first)
590 if(itr==it->second.end() || o.first<itr->first)
592 it->second.insert(o);
595 else if(itr!=it->second.end())
597 assert(itr->first==o.first);
599 for(
const auto &o_range : o.second)
600 more=
gen(itr->second, o_range.first, o_range.second) ||
607 values_innert::iterator itr=dest.begin();
608 for(
const auto &
id : other)
610 while(itr!=dest.end() && *itr<id)
612 if(itr==dest.end() ||
id<*itr)
614 dest.insert(itr,
id);
617 else if(itr!=dest.end())
637 valuest::iterator it=
values.begin();
638 for(
const auto &value : other.
values)
640 while(it!=
values.end() && it->first<value.first)
642 if(it==
values.end() || value.first<it->first)
649 assert(it->first==value.first);
681 valuest::iterator it=
values.begin();
682 for(
const auto &value : other.
values)
684 const irep_idt &identifier=value.first;
686 if(!ns.
lookup(identifier).is_shared()
690 while(it!=
values.end() && it->first<value.first)
692 if(it==
values.end() || value.first<it->first)
699 assert(it->first==value.first);
721 export_cachet::const_iterator entry=
export_cache.find(identifier);
726 return entry->second;
732 auto value_sets_=util_make_unique<value_set_analysis_fit>(
ns);
733 (*value_sets_)(goto_functions);
736 is_threaded=util_make_unique<is_threadedt>(goto_functions);
738 is_dirty=util_make_unique<dirtyt>(goto_functions);
void kill(const irep_idt &identifier, const range_spect &range_start, const range_spect &range_end)
#define INVARIANT_STRUCTURED(CONDITION, TYPENAME,...)
void transform(locationt from, locationt to, ai_baset &ai, const namespacet &ns) final override
virtual void initialize(const goto_functionst &goto_functions) override
Over-approximate Concurrency for Threaded Goto Programs.
#define forall_rw_range_set_w_objects(it, rw_set)
void clear_cache(const irep_idt &identifier) const
void transform_function_call(const namespacet &ns, locationt from, locationt to, reaching_definitions_analysist &rd)
ai_domain_baset::locationt definition_at
Variables whose address is taken.
const code_deadt & to_code_dead(const codet &code)
const code_typet & to_code_type(const typet &type)
Cast a generic typet to a code_typet.
const irep_idt & get_identifier() const
range_spect to_range_spect(const mp_integer &size)
std::unique_ptr< dirtyt > is_dirty
const dirtyt & get_is_dirty() const
virtual statet & get_state(goto_programt::const_targett l) override
void output(std::ostream &out, const ai_baset &ai, const namespacet &ns) const final override
bool merge_inner(values_innert &dest, const values_innert &other)
mp_integer pointer_offset_bits(const typet &type, const namespacet &ns)
Symbol table entry.This is a symbol in the symbol table, stored in an object of type symbol_tablet...
sparse_bitvector_analysist< reaching_definitiont > * bv_container
const char * to_string() const
virtual ~reaching_definitions_analysist()
void kill_inf(const irep_idt &identifier, const range_spect &range_start)
void populate_cache(const irep_idt &identifier) const
std::unordered_map< irep_idt, values_innert > valuest
bool gen(locationt from, const irep_idt &identifier, const range_spect &range_start, const range_spect &range_end)
instructionst::const_iterator const_targett
void goto_rw(goto_programt::const_targett target, const code_assignt &assign, rw_range_sett &rw_set)
std::unique_ptr< value_setst > value_sets
value_setst & get_value_sets() const
void transform_start_thread(const namespacet &ns, reaching_definitions_analysist &rd)
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast a generic exprt to a symbol_exprt.
void transform_dead(const namespacet &ns, locationt from)
bool merge_shared(const rd_range_domaint &other, locationt from, locationt to, const namespacet &ns)
Range-based reaching definitions analysis (following Field- Sensitive Program Dependence Analysis...
std::vector< typename inner_mapt::const_iterator > values
const V & get(const std::size_t value_index) const
bool merge(const rd_range_domaint &other, locationt from, locationt to)
const parameterst & parameters() const
export_cachet export_cache
reaching_definitions_analysist(const namespacet &_ns)
virtual void initialize(const goto_programt &)
std::size_t add(const V &value)
goto_programt::const_targett locationt
std::multimap< range_spect, range_spect > rangest
void transform_assign(const namespacet &ns, locationt from, locationt to, reaching_definitions_analysist &rd)
Expression to hold a symbol (variable)
Value Set Propagation (flow insensitive)
void transform_end_function(const namespacet &ns, locationt from, locationt to, reaching_definitions_analysist &rd)
std::unique_ptr< is_threadedt > is_threaded
std::map< locationt, rangest > ranges_at_loct
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See namespace_baset::lookup().
std::set< std::size_t > values_innert
const is_threadedt & get_is_threaded() const
const ranges_at_loct & get(const irep_idt &identifier) const
const code_function_callt & to_code_function_call(const codet &code)