Skip to content

Keep SSA L1 IDs as an attribute #396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/util/irep_ids.txt
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ C_full_identifier #full_identifier
L0
L1
L2
L1_object_identifier
already_typechecked
C_va_arg_type #va_arg_type
smt2_symbol
Expand Down
24 changes: 17 additions & 7 deletions src/util/ssa_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,22 @@ static void build_ssa_identifier_rec(
const irep_idt &l0,
const irep_idt &l1,
const irep_idt &l2,
std::ostream &os)
std::ostream &os,
std::ostream &l1_object_os)
{
if(expr.id()==ID_member)
{
const member_exprt &member=to_member_expr(expr);

build_ssa_identifier_rec(member.struct_op(), l0, l1, l2, os);
build_ssa_identifier_rec(member.struct_op(), l0, l1, l2, os, l1_object_os);

os << '.' << member.get_component_name();
}
else if(expr.id()==ID_index)
{
const index_exprt &index=to_index_expr(expr);

build_ssa_identifier_rec(index.array(), l0, l1, l2, os);
build_ssa_identifier_rec(index.array(), l0, l1, l2, os, l1_object_os);

mp_integer idx;
if(to_integer(to_constant_expr(index.index()), idx))
Expand All @@ -54,13 +55,21 @@ static void build_ssa_identifier_rec(
}
else if(expr.id()==ID_symbol)
{
os << to_symbol_expr(expr).get_identifier();
auto symid=to_symbol_expr(expr).get_identifier();
os << symid;
l1_object_os << symid;

if(!l0.empty())
{
os << '!' << l0;
l1_object_os << '!' << l0;
}

if(!l1.empty())
{
os << '@' << l1;
l1_object_os << '@' << l1;
}

if(!l2.empty())
os << '#' << l2;
Expand All @@ -81,15 +90,16 @@ Function: ssa_exprt::build_identifier

\*******************************************************************/

irep_idt ssa_exprt::build_identifier(
std::pair<irep_idt, irep_idt> ssa_exprt::build_identifier(
const exprt &expr,
const irep_idt &l0,
const irep_idt &l1,
const irep_idt &l2)
{
std::ostringstream oss;
std::ostringstream l1_object_oss;

build_ssa_identifier_rec(expr, l0, l1, l2, oss);
build_ssa_identifier_rec(expr, l0, l1, l2, oss, l1_object_oss);

return oss.str();
return std::make_pair(irep_idt(oss.str()), irep_idt(l1_object_oss.str()));
}
18 changes: 7 additions & 11 deletions src/util/ssa_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,9 @@ class ssa_exprt:public symbol_exprt
#if 0
return get_l1_object().get_identifier();
#else
// the above is the clean version, this is the fast one, making
// use of internal knowledge about identifier names
std::string l1_o_id=id2string(get_identifier());
std::string::size_type fs_suffix=l1_o_id.find_first_of(".[#");

if(fs_suffix!=std::string::npos)
l1_o_id.resize(fs_suffix);

return l1_o_id;
// the above is the clean version, this is the fast one, using
// an identifier cached during build_identifier
return get(ID_L1_object_identifier);
#endif
}

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

set_identifier(build_identifier(get_original_expr(), l0, l1, l2));
auto idpair=build_identifier(get_original_expr(), l0, l1, l2);
set_identifier(idpair.first);
set(ID_L1_object_identifier, idpair.second);
}

static irep_idt build_identifier(
static std::pair<irep_idt, irep_idt> build_identifier(
const exprt &src,
const irep_idt &l0,
const irep_idt &l1,
Expand Down