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)
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())
132 if(to->is_function_call())
140 const bool is_must_alias=rw_set.
get_w_set().size()==1;
142 for(
const auto &written_object_entry : rw_set.
get_w_set())
144 const irep_idt &identifier = written_object_entry.first;
147 if(ns.
lookup(identifier, symbol_ptr))
149 assert(symbol_ptr!=0);
152 rw_set.
get_ranges(written_object_entry.second);
158 for(
const auto &range : ranges)
159 kill(identifier, range.first, range.second);
172 const irep_idt &identifier = from->dead_symbol().get_identifier();
174 valuest::iterator entry=
values.find(identifier);
187 for(valuest::iterator it=
values.begin();
191 const irep_idt &identifier=it->first;
193 if(!ns.
lookup(identifier).is_shared() &&
198 valuest::iterator next=it;
216 if(function_from != function_to)
218 for(valuest::iterator it=
values.begin();
222 const irep_idt &identifier=it->first;
226 if((ns.
lookup(identifier, sym) ||
232 valuest::iterator next=it;
245 for(
const auto ¶m : code_type.
parameters())
247 const irep_idt &identifier=param.get_identifier();
249 if(identifier.
empty())
253 if(param_bits.has_value())
256 gen(from, identifier, 0, -1);
262 if(from->call_lhs().is_not_nil())
282 for(
const auto &new_value : new_values)
284 const irep_idt &identifier=new_value.first;
287 (!ns.
lookup(identifier).is_shared() &&
290 for(
const auto &
id : new_value.second)
297 for(
const auto &
id : new_value.second)
306 for(
const auto ¶m : code_type.
parameters())
308 const irep_idt &identifier=param.get_identifier();
310 if(identifier.
empty())
313 valuest::iterator entry=
values.find(identifier);
323 if(call->call_lhs().is_not_nil())
343 goto_rw(function_to, to, rw_set);
344 const bool is_must_alias=rw_set.
get_w_set().size()==1;
346 for(
const auto &written_object_entry : rw_set.
get_w_set())
348 const irep_idt &identifier = written_object_entry.first;
351 if(ns.
lookup(identifier, symbol_ptr))
356 "Symbol is in symbol table");
359 rw_set.
get_ranges(written_object_entry.second);
365 for(
const auto &range : ranges)
366 kill(identifier, range.first, range.second);
368 for(
const auto &range : ranges)
369 gen(from, identifier, range.first, range.second);
378 assert(range_start>=0);
386 assert(range_end>range_start);
388 valuest::iterator entry=
values.find(identifier);
392 bool clear_export_cache=
false;
395 for(values_innert::iterator
396 it=entry->second.begin();
397 it!=entry->second.end();
411 clear_export_cache=
true;
413 entry->second.erase(it++);
417 clear_export_cache=
true;
423 entry->second.erase(it++);
428 clear_export_cache=
true;
439 entry->second.erase(it++);
443 clear_export_cache=
true;
449 entry->second.erase(it++);
453 if(clear_export_cache)
456 values_innert::iterator it=entry->second.begin();
457 for(
const auto &
id : new_values)
459 while(it!=entry->second.end() && *it<
id)
461 if(it==entry->second.end() ||
id<*it)
463 entry->second.insert(it,
id);
465 else if(it!=entry->second.end())
477 assert(range_start>=0);
480 valuest::iterator entry=
values.find(identifier);
484 XXX export_cache_available=
false;
489 for(rangest::iterator it=ranges.begin();
492 if(it->second.first!=-1 &&
493 it->second.first <= range_start)
495 else if(it->first >= range_start)
501 it->second.first=range_start;
518 if(range_start==0 && range_end==0)
521 assert(range_start>=0);
524 assert(range_end>range_start || range_end==-1);
540 std::pair<valuest::iterator, bool> entry=
542 rangest &ranges=entry.first->second;
546 for(rangest::iterator it=ranges.begin();
550 if(it->second.second!=from ||
551 (it->second.first!=-1 && it->second.first <= range_start) ||
552 (range_end!=-1 && it->first >= range_end))
554 else if(it->first > range_start)
557 merged_range_end=std::max(range_end, it->second.first);
560 else if(it->second.first==-1 ||
562 it->second.first >= range_end))
569 it->second.first=range_end;
575 ranges.insert(std::make_pair(
577 std::make_pair(merged_range_end, from)));
585 out <<
"Reaching definitions:\n";
593 for(
const auto &value :
values)
595 const irep_idt &identifier=value.first;
599 out <<
" " << identifier <<
"[";
601 for(ranges_at_loct::const_iterator itl=ranges.begin();
604 for(rangest::const_iterator itr=itl->second.begin();
605 itr!=itl->second.end();
608 if(itr!=itl->second.begin() ||
612 out << itr->first <<
":" << itr->second;
613 out <<
"@" << itl->first->location_number;
630 ranges_at_loct::iterator itr=it->second.begin();
631 for(
const auto &o : ito->second)
633 while(itr!=it->second.end() && itr->first<o.first)
635 if(itr==it->second.end() || o.first<itr->first)
637 it->second.insert(o);
640 else if(itr!=it->second.end())
642 assert(itr->first==o.first);
644 for(
const auto &o_range : o.second)
645 more=
gen(itr->second, o_range.first, o_range.second) ||
652 values_innert::iterator itr=dest.begin();
653 for(
const auto &
id : other)
655 while(itr!=dest.end() && *itr<
id)
657 if(itr==dest.end() ||
id<*itr)
659 dest.insert(itr,
id);
662 else if(itr!=dest.end())
681 valuest::iterator it=
values.begin();
682 for(
const auto &value : other.
values)
684 while(it!=
values.end() && it->first<value.first)
686 if(it==
values.end() || value.first<it->first)
693 assert(it->first==value.first);
725 valuest::iterator it=
values.begin();
726 for(
const auto &value : other.
values)
728 const irep_idt &identifier=value.first;
730 if(!ns.
lookup(identifier).is_shared()
734 while(it!=
values.end() && it->first<value.first)
736 if(it==
values.end() || value.first<it->first)
743 assert(it->first==value.first);
765 export_cachet::const_iterator entry=
export_cache.find(identifier);
770 return entry->second;
776 auto value_sets_=util_make_unique<value_set_analysis_fit>(
ns);
777 (*value_sets_)(goto_functions);
780 is_threaded=util_make_unique<is_threadedt>(goto_functions);
782 is_dirty=util_make_unique<dirtyt>(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_baset::locationt locationt
virtual statet & get_state(locationt l)
codet representation of a function call statement.
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().
This ensures that all domains are constructed with the appropriate pointer back to the analysis engin...
sparse_bitvector_analysist< reaching_definitiont > *const bv_container
rd_range_domain_factoryt(sparse_bitvector_analysist< reaching_definitiont > *_bv_container)
std::unique_ptr< statet > make(locationt) const override
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)
std::map< locationt, rangest > ranges_at_loct
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)
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
const is_threadedt & get_is_threaded() const
virtual ~reaching_definitions_analysist()
std::unique_ptr< is_threadedt > is_threaded
reaching_definitions_analysist(const namespacet &_ns)
std::unique_ptr< dirtyt > is_dirty
std::unique_ptr< value_setst > value_sets
value_setst & get_value_sets() const
const dirtyt & get_is_dirty() const
void initialize(const goto_functionst &goto_functions) override
Initialize all the abstract states for a whole program.
const range_domaint & get_ranges(const std::unique_ptr< range_domain_baset > &ranges) const
const objectst & get_w_set() const
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.
const code_function_callt & to_code_function_call(const codet &code)
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)
range_spect to_range_spect(const mp_integer &size)
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 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)