Skip to content

Commit fc5ca14

Browse files
committed
Updated LVSA data structures for Recency Analysis
Added recency to dynamic-objects' class. Minor coding style changes to the recency output of the LVSA.
1 parent 2ef3925 commit fc5ca14

File tree

3 files changed

+62
-19
lines changed

3 files changed

+62
-19
lines changed

src/pointer-analysis/value_set.cpp

+23-19
Original file line numberDiff line numberDiff line change
@@ -194,22 +194,18 @@ void value_sett::output(
194194
result=from_expr(ns, identifier, o);
195195
else
196196
{
197+
result="<"+from_expr(ns, identifier, o)+", ";
197198
if(o.id()==ID_dynamic_object)
198199
{
199-
dynamic_object_exprt::recencyt recency;
200-
std::string recency_str="";
201-
202-
recency=to_dynamic_object_expr(o).get_recency();
200+
dynamic_object_exprt::recencyt recency=
201+
to_dynamic_object_expr(o).get_recency();
202+
203203
if(recency==dynamic_object_exprt::recencyt::MOST_RECENT_ALLOCATION)
204-
recency_str="most-recent-allocation";
204+
result+=as_string(ID_most_recent_allocation)+", ";
205205
else if(recency==dynamic_object_exprt::recencyt::ANY_ALLOCATION)
206-
recency_str="any-allocation";
207-
result="<"+from_expr(ns, identifier, o)+", "+recency_str+", ";
208-
}
209-
else
210-
{
211-
result="<"+from_expr(ns, identifier, o)+", ";
206+
result+=as_string(ID_any_allocation)+", ";
212207
}
208+
213209
if(o_it->second.offset_is_set)
214210
result+=integer2string(o_it->second.offset)+"";
215211
else
@@ -911,11 +907,15 @@ void value_sett::get_value_set_rec(
911907
std::string recency_str="";
912908

913909
if(dynamic_object.get_recency()==
914-
dynamic_object_exprt::recencyt::MOST_RECENT_ALLOCATION)
915-
recency_str="most-recent-allocation";
910+
dynamic_object_exprt::recencyt::MOST_RECENT_ALLOCATION)
911+
{
912+
recency_str=as_string(ID_most_recent_allocation);
913+
}
916914
else if(dynamic_object.get_recency()==
917-
dynamic_object_exprt::recencyt::ANY_ALLOCATION)
918-
recency_str="any-allocation";
915+
dynamic_object_exprt::recencyt::ANY_ALLOCATION)
916+
{
917+
recency_str=as_string(ID_any_allocation);
918+
}
919919

920920
const std::string prefix=
921921
"value_set::dynamic_object"+
@@ -1558,11 +1558,15 @@ void value_sett::assign_rec(
15581558
std::string recency_str="";
15591559

15601560
if(dynamic_object.get_recency()==
1561-
dynamic_object_exprt::recencyt::MOST_RECENT_ALLOCATION)
1562-
recency_str="most-recent-allocation";
1561+
dynamic_object_exprt::recencyt::MOST_RECENT_ALLOCATION)
1562+
{
1563+
recency_str=as_string(ID_most_recent_allocation);
1564+
}
15631565
else if(dynamic_object.get_recency()==
1564-
dynamic_object_exprt::recencyt::ANY_ALLOCATION)
1565-
recency_str="any-allocation";
1566+
dynamic_object_exprt::recencyt::ANY_ALLOCATION)
1567+
{
1568+
recency_str=as_string(ID_any_allocation);
1569+
}
15661570

15671571
const std::string name=
15681572
"value_set::dynamic_object"+

src/util/irep_ids.txt

+3
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,9 @@ overflow_mult overflow-*
511511
overflow_unary_minus overflow-unary-
512512
object_descriptor
513513
dynamic_object
514+
is_most_recent_allocation
515+
most_recent_allocation
516+
any_allocation
514517
object_size
515518
good_pointer
516519
integer_address

src/util/std_expr.h

+36
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,8 @@ inline object_descriptor_exprt &to_object_descriptor_expr(exprt &expr)
14901490
class dynamic_object_exprt:public exprt
14911491
{
14921492
public:
1493+
enum recencyt { MOST_RECENT_ALLOCATION, ANY_ALLOCATION, RECENCY_UNSET };
1494+
14931495
dynamic_object_exprt():exprt(ID_dynamic_object)
14941496
{
14951497
operands().resize(2);
@@ -1505,6 +1507,40 @@ class dynamic_object_exprt:public exprt
15051507
op1().id(ID_unknown);
15061508
}
15071509

1510+
explicit dynamic_object_exprt(bool recent):
1511+
exprt(ID_dynamic_object)
1512+
{
1513+
operands().resize(2);
1514+
op0().id(ID_unknown);
1515+
op1().id(ID_unknown);
1516+
set_recency(recent);
1517+
}
1518+
1519+
dynamic_object_exprt(const typet &type, bool recent):
1520+
exprt(ID_dynamic_object, type)
1521+
{
1522+
operands().resize(2);
1523+
op0().id(ID_unknown);
1524+
op1().id(ID_unknown);
1525+
set_recency(recent);
1526+
}
1527+
1528+
recencyt get_recency() const
1529+
{
1530+
if(get(ID_is_most_recent_allocation)==ID_most_recent_allocation)
1531+
return MOST_RECENT_ALLOCATION;
1532+
else if(get(ID_is_most_recent_allocation)==ID_any_allocation)
1533+
return ANY_ALLOCATION;
1534+
else
1535+
return RECENCY_UNSET;
1536+
}
1537+
1538+
void set_recency(bool recent)
1539+
{
1540+
set(ID_is_most_recent_allocation,
1541+
(recent ? ID_most_recent_allocation : ID_any_allocation));
1542+
}
1543+
15081544
exprt &instance()
15091545
{
15101546
return op0();

0 commit comments

Comments
 (0)