Skip to content

Commit 1c42040

Browse files
author
Daniel Kroening
authored
Merge pull request #396 from smowton/fix_ssa_l1_ids
Keep SSA L1 IDs as an attribute
2 parents ae8da63 + d9026ae commit 1c42040

File tree

3 files changed

+25
-18
lines changed

3 files changed

+25
-18
lines changed

src/util/irep_ids.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ C_full_identifier #full_identifier
693693
L0
694694
L1
695695
L2
696+
L1_object_identifier
696697
already_typechecked
697698
C_va_arg_type #va_arg_type
698699
smt2_symbol

src/util/ssa_expr.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,22 @@ static void build_ssa_identifier_rec(
3030
const irep_idt &l0,
3131
const irep_idt &l1,
3232
const irep_idt &l2,
33-
std::ostream &os)
33+
std::ostream &os,
34+
std::ostream &l1_object_os)
3435
{
3536
if(expr.id()==ID_member)
3637
{
3738
const member_exprt &member=to_member_expr(expr);
3839

39-
build_ssa_identifier_rec(member.struct_op(), l0, l1, l2, os);
40+
build_ssa_identifier_rec(member.struct_op(), l0, l1, l2, os, l1_object_os);
4041

4142
os << '.' << member.get_component_name();
4243
}
4344
else if(expr.id()==ID_index)
4445
{
4546
const index_exprt &index=to_index_expr(expr);
4647

47-
build_ssa_identifier_rec(index.array(), l0, l1, l2, os);
48+
build_ssa_identifier_rec(index.array(), l0, l1, l2, os, l1_object_os);
4849

4950
mp_integer idx;
5051
if(to_integer(to_constant_expr(index.index()), idx))
@@ -54,13 +55,21 @@ static void build_ssa_identifier_rec(
5455
}
5556
else if(expr.id()==ID_symbol)
5657
{
57-
os << to_symbol_expr(expr).get_identifier();
58+
auto symid=to_symbol_expr(expr).get_identifier();
59+
os << symid;
60+
l1_object_os << symid;
5861

5962
if(!l0.empty())
63+
{
6064
os << '!' << l0;
65+
l1_object_os << '!' << l0;
66+
}
6167

6268
if(!l1.empty())
69+
{
6370
os << '@' << l1;
71+
l1_object_os << '@' << l1;
72+
}
6473

6574
if(!l2.empty())
6675
os << '#' << l2;
@@ -81,15 +90,16 @@ Function: ssa_exprt::build_identifier
8190
8291
\*******************************************************************/
8392

84-
irep_idt ssa_exprt::build_identifier(
93+
std::pair<irep_idt, irep_idt> ssa_exprt::build_identifier(
8594
const exprt &expr,
8695
const irep_idt &l0,
8796
const irep_idt &l1,
8897
const irep_idt &l2)
8998
{
9099
std::ostringstream oss;
100+
std::ostringstream l1_object_oss;
91101

92-
build_ssa_identifier_rec(expr, l0, l1, l2, oss);
102+
build_ssa_identifier_rec(expr, l0, l1, l2, oss, l1_object_oss);
93103

94-
return oss.str();
104+
return std::make_pair(irep_idt(oss.str()), irep_idt(l1_object_oss.str()));
95105
}

src/util/ssa_expr.h

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,9 @@ class ssa_exprt:public symbol_exprt
6767
#if 0
6868
return get_l1_object().get_identifier();
6969
#else
70-
// the above is the clean version, this is the fast one, making
71-
// use of internal knowledge about identifier names
72-
std::string l1_o_id=id2string(get_identifier());
73-
std::string::size_type fs_suffix=l1_o_id.find_first_of(".[#");
74-
75-
if(fs_suffix!=std::string::npos)
76-
l1_o_id.resize(fs_suffix);
77-
78-
return l1_o_id;
70+
// the above is the clean version, this is the fast one, using
71+
// an identifier cached during build_identifier
72+
return get(ID_L1_object_identifier);
7973
#endif
8074
}
8175

@@ -130,10 +124,12 @@ class ssa_exprt:public symbol_exprt
130124
const irep_idt &l1=get_level_1();
131125
const irep_idt &l2=get_level_2();
132126

133-
set_identifier(build_identifier(get_original_expr(), l0, l1, l2));
127+
auto idpair=build_identifier(get_original_expr(), l0, l1, l2);
128+
set_identifier(idpair.first);
129+
set(ID_L1_object_identifier, idpair.second);
134130
}
135131

136-
static irep_idt build_identifier(
132+
static std::pair<irep_idt, irep_idt> build_identifier(
137133
const exprt &src,
138134
const irep_idt &l0,
139135
const irep_idt &l1,

0 commit comments

Comments
 (0)