Skip to content

Commit c8f0f7b

Browse files
author
kroening
committed
new L1 locality
git-svn-id: svn+ssh://svn.cprover.org/srv/svn/cbmc/trunk@892 6afb6bc1-c8e4-404c-8f48-9ae832c5b171
1 parent d5e54ff commit c8f0f7b

File tree

4 files changed

+35
-36
lines changed

4 files changed

+35
-36
lines changed

src/goto-symex/goto_symex_state.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,9 @@ void goto_symex_statet::assignment(
286286
#endif
287287

288288
// do the l2 renaming
289-
unsigned &count=level2.current_names[l1_identifier];
290-
291-
count++;
292-
293-
level2.rename(l1_identifier, count);
294-
295-
lhs.set_identifier(level2.name(l1_identifier, count));
289+
unsigned new_count=level2.current_count(l1_identifier)+1;
290+
level2.rename(l1_identifier, new_count);
291+
lhs.set_identifier(level2.name(l1_identifier, new_count));
296292

297293
// for value propagation -- the RHS is L2
298294

src/goto-symex/goto_symex_state.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ class goto_symex_statet
3737
// we have a two-level renaming
3838

3939
typedef std::map<irep_idt, irep_idt> original_identifierst;
40-
typedef std::set<irep_idt> declaration_historyt;
4140

42-
// we remember all declarations
43-
declaration_historyt declaration_history;
41+
// we remember all L1 renamings
42+
typedef std::set<irep_idt> l1_historyt;
43+
l1_historyt l1_history;
4444

4545
struct renaming_levelt
4646
{
@@ -58,7 +58,7 @@ class goto_symex_statet
5858
void get_original_name(typet &type) const;
5959
void print(std::ostream &out) const;
6060
unsigned current_count(const irep_idt &identifier) const;
61-
61+
6262
irep_idt operator()(const irep_idt &identifier)
6363
{
6464
// see if it's already renamed
@@ -172,7 +172,7 @@ class goto_symex_statet
172172
// _always_ rename
173173
return name(identifier, current_count(identifier));
174174
}
175-
175+
176176
level2t() { }
177177
virtual ~level2t() { }
178178
} level2;

src/goto-symex/symex_decl.cpp

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,21 @@ void goto_symext::symex_decl(statet &state)
4343
if(code.op0().id()!=ID_symbol)
4444
throw "decl expects symbol as first operand";
4545

46-
// just do the L1 renaming to preserve locality
46+
// We increase the L2 renaming to make these non-deterministic.
47+
// We also prevent propagation of old values.
48+
4749
const irep_idt &identifier=
4850
to_symbol_expr(code.op0()).get_identifier();
4951

50-
const irep_idt l0_identifier=
51-
state.rename(identifier, ns, goto_symex_statet::L0);
52+
const irep_idt l1_identifier=
53+
state.rename(identifier, ns, goto_symex_statet::L1);
5254

53-
irep_idt l1_identifier;
54-
55-
do
56-
{
57-
unsigned index=state.top().level1.current_names[l0_identifier];
58-
state.top().level1.rename(l0_identifier, index+1);
59-
l1_identifier=state.top().level1(l0_identifier);
60-
}
61-
while(state.declaration_history.find(l1_identifier)!=
62-
state.declaration_history.end());
63-
64-
// forget the old L2 renaming to avoid SSA for it
65-
state.level2.remove(l1_identifier);
55+
// prevent propagation
6656
state.propagation.remove(l1_identifier);
67-
state.declaration_history.insert(l1_identifier);
68-
69-
state.top().local_variables.insert(l1_identifier);
57+
58+
// L2 renaming
59+
unsigned new_count=state.level2.current_count(l1_identifier)+1;
60+
state.level2.rename(l1_identifier, new_count);
7061

7162
// in case of pointers, put something into the value set
7263
if(ns.follow(code.op0().type()).id()==ID_pointer)

src/goto-symex/symex_function.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,24 @@ void goto_symext::locality(
388388
// get L0 name
389389
irep_idt l0_name=state.rename(*it, ns, goto_symex_statet::L0);
390390

391-
// do L1 renaming
392-
frame.level1.rename(l0_name, frame_nr);
393-
394-
// store
395-
irep_idt l1_name=frame.level1(l0_name);
391+
// do L1 renaming -- these need not be unique, as
392+
// identifiers may be shared among functions
393+
// (e.g., due to inlining or other code restructuring)
394+
395+
irep_idt l1_name;
396+
unsigned offset=0;
397+
398+
do
399+
{
400+
frame.level1.rename(l0_name, frame_nr+offset);
401+
l1_name=frame.level1(l0_name);
402+
offset++;
403+
}
404+
while(state.l1_history.find(l1_name)!=state.l1_history.end());
405+
406+
// now unique -- store
396407
frame.local_variables.insert(l1_name);
408+
state.l1_history.insert(l1_name);
397409
}
398410
}
399411

0 commit comments

Comments
 (0)