Skip to content

Commit 8b08259

Browse files
author
martin
committed
Fix simpilar issues in other places in pointer-analysis.
It seems that there is a spurious loop over all instructions. I suspect this is a copy and paste error from location sensitive code.
1 parent fb4c4d1 commit 8b08259

File tree

2 files changed

+46
-68
lines changed

2 files changed

+46
-68
lines changed

src/pointer-analysis/value_set_analysis_fivr.cpp

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -84,33 +84,26 @@ void value_set_analysis_fivrt::add_vars(
8484
entry_cachet entry_cache;
8585

8686
value_set_fivrt &v=state.value_set;
87+
v.add_vars(globals);
8788

88-
for(goto_programt::instructionst::const_iterator
89-
i_it=goto_program.instructions.begin();
90-
i_it!=goto_program.instructions.end();
91-
i_it++)
89+
for(goto_programt::decl_identifierst::const_iterator
90+
l_it=locals.begin();
91+
l_it!=locals.end();
92+
l_it++)
9293
{
93-
v.add_vars(globals);
94+
// cache hit?
95+
entry_cachet::const_iterator e_it=entry_cache.find(*l_it);
9496

95-
for(goto_programt::decl_identifierst::const_iterator
96-
l_it=locals.begin();
97-
l_it!=locals.end();
98-
l_it++)
97+
if(e_it==entry_cache.end())
9998
{
100-
// cache hit?
101-
entry_cachet::const_iterator e_it=entry_cache.find(*l_it);
99+
const symbolt &symbol=ns.lookup(*l_it);
102100

103-
if(e_it==entry_cache.end())
104-
{
105-
const symbolt &symbol=ns.lookup(*l_it);
106-
107-
std::list<value_set_fivrt::entryt> &entries=entry_cache[*l_it];
108-
get_entries(symbol, entries);
109-
v.add_vars(entries);
110-
}
111-
else
112-
v.add_vars(e_it->second);
101+
std::list<value_set_fivrt::entryt> &entries=entry_cache[*l_it];
102+
get_entries(symbol, entries);
103+
v.add_vars(entries);
113104
}
105+
else
106+
v.add_vars(e_it->second);
114107
}
115108
}
116109

@@ -202,6 +195,7 @@ void value_set_analysis_fivrt::add_vars(
202195
get_globals(globals);
203196

204197
value_set_fivrt &v=state.value_set;
198+
v.add_vars(globals);
205199

206200
for(goto_functionst::function_mapt::const_iterator
207201
f_it=goto_functions.function_map.begin();
@@ -212,21 +206,16 @@ void value_set_analysis_fivrt::add_vars(
212206
std::set<irep_idt> locals;
213207
get_local_identifiers(f_it->second, locals);
214208

215-
forall_goto_program_instructions(i_it, f_it->second.body)
209+
for(std::set<irep_idt>::const_iterator
210+
l_it=locals.begin();
211+
l_it!=locals.end();
212+
l_it++)
216213
{
217-
v.add_vars(globals);
214+
const symbolt &symbol=ns.lookup(*l_it);
218215

219-
for(std::set<irep_idt>::const_iterator
220-
l_it=locals.begin();
221-
l_it!=locals.end();
222-
l_it++)
223-
{
224-
const symbolt &symbol=ns.lookup(*l_it);
225-
226-
std::list<value_set_fivrt::entryt> entries;
227-
get_entries(symbol, entries);
228-
v.add_vars(entries);
229-
}
216+
std::list<value_set_fivrt::entryt> entries;
217+
get_entries(symbol, entries);
218+
v.add_vars(entries);
230219
}
231220
}
232221
}

src/pointer-analysis/value_set_analysis_fivrns.cpp

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -84,33 +84,26 @@ void value_set_analysis_fivrnst::add_vars(
8484
entry_cachet entry_cache;
8585

8686
value_set_fivrnst &v=state.value_set;
87+
v.add_vars(globals);
8788

88-
for(goto_programt::instructionst::const_iterator
89-
i_it=goto_program.instructions.begin();
90-
i_it!=goto_program.instructions.end();
91-
i_it++)
89+
for(goto_programt::decl_identifierst::const_iterator
90+
l_it=locals.begin();
91+
l_it!=locals.end();
92+
l_it++)
9293
{
93-
v.add_vars(globals);
94+
// cache hit?
95+
entry_cachet::const_iterator e_it=entry_cache.find(*l_it);
9496

95-
for(goto_programt::decl_identifierst::const_iterator
96-
l_it=locals.begin();
97-
l_it!=locals.end();
98-
l_it++)
97+
if(e_it==entry_cache.end())
9998
{
100-
// cache hit?
101-
entry_cachet::const_iterator e_it=entry_cache.find(*l_it);
99+
const symbolt &symbol=ns.lookup(*l_it);
102100

103-
if(e_it==entry_cache.end())
104-
{
105-
const symbolt &symbol=ns.lookup(*l_it);
106-
107-
std::list<value_set_fivrnst::entryt> &entries=entry_cache[*l_it];
108-
get_entries(symbol, entries);
109-
v.add_vars(entries);
110-
}
111-
else
112-
v.add_vars(e_it->second);
101+
std::list<value_set_fivrnst::entryt> &entries=entry_cache[*l_it];
102+
get_entries(symbol, entries);
103+
v.add_vars(entries);
113104
}
105+
else
106+
v.add_vars(e_it->second);
114107
}
115108
}
116109

@@ -202,6 +195,7 @@ void value_set_analysis_fivrnst::add_vars(
202195
get_globals(globals);
203196

204197
value_set_fivrnst &v=state.value_set;
198+
v.add_vars(globals);
205199

206200
for(goto_functionst::function_mapt::const_iterator
207201
f_it=goto_functions.function_map.begin();
@@ -212,21 +206,16 @@ void value_set_analysis_fivrnst::add_vars(
212206
std::set<irep_idt> locals;
213207
get_local_identifiers(f_it->second, locals);
214208

215-
forall_goto_program_instructions(i_it, f_it->second.body)
209+
for(std::set<irep_idt>::const_iterator
210+
l_it=locals.begin();
211+
l_it!=locals.end();
212+
l_it++)
216213
{
217-
v.add_vars(globals);
214+
const symbolt &symbol=ns.lookup(*l_it);
218215

219-
for(std::set<irep_idt>::const_iterator
220-
l_it=locals.begin();
221-
l_it!=locals.end();
222-
l_it++)
223-
{
224-
const symbolt &symbol=ns.lookup(*l_it);
225-
226-
std::list<value_set_fivrnst::entryt> entries;
227-
get_entries(symbol, entries);
228-
v.add_vars(entries);
229-
}
216+
std::list<value_set_fivrnst::entryt> entries;
217+
get_entries(symbol, entries);
218+
v.add_vars(entries);
230219
}
231220
}
232221
}

0 commit comments

Comments
 (0)