Skip to content

Commit 8418997

Browse files
Use rename_level1_ssa where possible
In places where rename<L1> is known to be called on an ssa_exprt, we replace the call by a call to rename_level1_ssa to avoid unecessary decision making and show more information in the return type.
1 parent bc55ae7 commit 8418997

7 files changed

+20
-23
lines changed

src/goto-symex/goto_symex_state.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void goto_symex_statet::assignment(
162162
bool allow_pointer_unsoundness)
163163
{
164164
// identifier should be l0 or l1, make sure it's l1
165-
rename<L1>(lhs, ns);
165+
lhs = rename_level1_ssa(std::move(lhs), ns);
166166
irep_idt l1_identifier=lhs.get_identifier();
167167

168168
// the type might need renaming

src/goto-symex/symex_dead.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ void goto_symext::symex_dead(statet &state)
2626
// We increase the L2 renaming to make these non-deterministic.
2727
// We also prevent propagation of old values.
2828

29-
ssa_exprt ssa(code.symbol());
30-
state.rename<goto_symex_statet::L1>(ssa, ns);
29+
ssa_exprt ssa = state.rename_level1_ssa(ssa_exprt{code.symbol()}, ns);
3130

3231
// in case of pointers, put something into the value set
3332
if(code.symbol().type().id() == ID_pointer)
@@ -42,8 +41,7 @@ void goto_symext::symex_dead(statet &state)
4241
state.value_set.assign(ssa, rhs, ns, true, false);
4342
}
4443

45-
ssa_exprt ssa_lhs=to_ssa_expr(ssa);
46-
const irep_idt &l1_identifier=ssa_lhs.get_identifier();
44+
const irep_idt &l1_identifier = ssa.get_identifier();
4745

4846
// prevent propagation
4947
state.propagation.erase(l1_identifier);

src/goto-symex/symex_decl.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ void goto_symext::symex_decl(statet &state, const symbol_exprt &expr)
3737
// We increase the L2 renaming to make these non-deterministic.
3838
// We also prevent propagation of old values.
3939

40-
ssa_exprt ssa(expr);
41-
state.rename<goto_symex_statet::L1>(ssa, ns);
42-
const irep_idt &l1_identifier=ssa.get_identifier();
40+
ssa_exprt ssa = state.rename_level1_ssa(ssa_exprt{expr}, ns);
41+
const irep_idt &l1_identifier = ssa.get_identifier();
4342

4443
// rename type to L2
4544
state.rename(ssa.type(), l1_identifier, ns);

src/goto-symex/symex_dereference_state.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ symex_dereference_statet::get_or_create_failed_symbol(const exprt &expr)
5050
{
5151
symbolt sym=*symbol;
5252
symbolt *sym_ptr=nullptr;
53-
symbol_exprt sym_expr=sym.symbol_expr();
54-
state.rename<goto_symex_statet::L1>(sym_expr, ns);
55-
sym.name=to_ssa_expr(sym_expr).get_identifier();
53+
const ssa_exprt sym_expr =
54+
state.rename_level1_ssa(ssa_exprt{sym.symbol_expr()}, ns);
55+
sym.name = sym_expr.get_identifier();
5656
state.symbol_table.move(sym, sym_ptr);
5757
return sym_ptr;
5858
}
@@ -70,9 +70,9 @@ symex_dereference_statet::get_or_create_failed_symbol(const exprt &expr)
7070
{
7171
symbolt sym=*symbol;
7272
symbolt *sym_ptr=nullptr;
73-
symbol_exprt sym_expr=sym.symbol_expr();
74-
state.rename<goto_symex_statet::L1>(sym_expr, ns);
75-
sym.name=to_ssa_expr(sym_expr).get_identifier();
73+
const ssa_exprt sym_expr =
74+
state.rename_level1_ssa(ssa_exprt{sym.symbol_expr()}, ns);
75+
sym.name = sym_expr.get_identifier();
7676
state.symbol_table.move(sym, sym_ptr);
7777
return sym_ptr;
7878
}

src/goto-symex/symex_function_call.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,17 +418,17 @@ static void locality(
418418
// identifiers may be shared among functions
419419
// (e.g., due to inlining or other code restructuring)
420420

421-
state.rename<goto_symex_statet::L1>(ssa, ns);
421+
ssa_exprt ssa_l1 = state.rename_level1_ssa(std::move(ssa), ns);
422422

423-
irep_idt l1_name=ssa.get_identifier();
423+
irep_idt l1_name = ssa_l1.get_identifier();
424424
unsigned offset=0;
425425

426426
while(state.l1_history.find(l1_name)!=state.l1_history.end())
427427
{
428428
symex_renaming_levelt::increase_counter(c_it);
429429
++offset;
430-
ssa.set_level_1(frame_nr+offset);
431-
l1_name=ssa.get_identifier();
430+
ssa_l1.set_level_1(frame_nr + offset);
431+
l1_name = ssa_l1.get_identifier();
432432
}
433433

434434
// now unique -- store

src/goto-symex/symex_goto.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ void goto_symext::symex_goto(statet &state)
248248
symbol_exprt(statet::guard_identifier(), bool_typet());
249249
exprt new_rhs = boolean_negate(new_guard);
250250

251-
ssa_exprt new_lhs(guard_symbol_expr);
252-
state.rename<goto_symex_statet::L1>(new_lhs, ns);
251+
ssa_exprt new_lhs =
252+
state.rename_level1_ssa(ssa_exprt{guard_symbol_expr}, ns);
253253
state.assignment(new_lhs, new_rhs, ns, true, false);
254254

255255
guardt guard{true_exprt{}};

src/goto-symex/symex_start_thread.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ void goto_symext::symex_start_thread(statet &state)
7373
std::forward_as_tuple(lhs.get_l1_object_identifier()),
7474
std::forward_as_tuple(lhs, 0));
7575
CHECK_RETURN(emplace_result.second);
76-
state.rename<goto_symex_statet::L1>(lhs, ns);
77-
const irep_idt l1_name=lhs.get_l1_object_identifier();
76+
const ssa_exprt lhs_l1 = state.rename_level1_ssa(std::move(lhs), ns);
77+
const irep_idt l1_name = lhs_l1.get_l1_object_identifier();
7878
// store it
7979
state.l1_history.insert(l1_name);
8080
new_thread.call_stack.back().local_objects.insert(l1_name);
@@ -87,7 +87,7 @@ void goto_symext::symex_start_thread(statet &state)
8787
state.record_events=false;
8888
symex_assign_symbol(
8989
state,
90-
lhs,
90+
lhs_l1,
9191
nil_exprt(),
9292
rhs,
9393
guard,

0 commit comments

Comments
 (0)