Skip to content

Commit 73fbad9

Browse files
authored
Merge pull request #6528 from tautschnig/bitvector-analysis
Performance improvement and cleanup of local bitvector analysis
2 parents eeddb3f + 8834dc5 commit 73fbad9

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

src/analyses/local_bitvector_analysis.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ bool local_bitvector_analysist::merge(points_tot &a, points_tot &b)
4545
std::max(a.size(), b.size());
4646

4747
for(std::size_t i=0; i<max_index; i++)
48-
{
49-
if(a[i].merge(b[i]))
50-
result=true;
51-
}
48+
result |= a[i].merge(b[i]);
5249

5350
return result;
5451
}
@@ -73,7 +70,7 @@ void local_bitvector_analysist::assign_lhs(
7370

7471
if(is_tracked(identifier))
7572
{
76-
unsigned dest_pointer=pointers.number(identifier);
73+
const auto dest_pointer = pointers.number(identifier);
7774
flagst rhs_flags=get_rec(rhs, loc_info_src);
7875
loc_info_dest[dest_pointer]=rhs_flags;
7976
}
@@ -128,7 +125,7 @@ local_bitvector_analysist::flagst local_bitvector_analysist::get_rec(
128125
const irep_idt &identifier=to_symbol_expr(rhs).get_identifier();
129126
if(is_tracked(identifier))
130127
{
131-
unsigned src_pointer=pointers.number(identifier);
128+
const auto src_pointer = pointers.number(identifier);
132129
return loc_info_src[src_pointer];
133130
}
134131
else
@@ -242,8 +239,8 @@ void local_bitvector_analysist::build()
242239
if(cfg.nodes.empty())
243240
return;
244241

245-
work_queuet work_queue;
246-
work_queue.push(0);
242+
std::set<local_cfgt::node_nrt> work_queue;
243+
work_queue.insert(0);
247244

248245
loc_infos.resize(cfg.nodes.size());
249246

@@ -258,10 +255,10 @@ void local_bitvector_analysist::build()
258255

259256
while(!work_queue.empty())
260257
{
261-
unsigned loc_nr=work_queue.top();
258+
const auto loc_nr = *work_queue.begin();
262259
const local_cfgt::nodet &node=cfg.nodes[loc_nr];
263260
const goto_programt::instructiont &instruction=*node.t;
264-
work_queue.pop();
261+
work_queue.erase(work_queue.begin());
265262

266263
auto &loc_info_src=loc_infos[loc_nr];
267264
auto loc_info_dest=loc_infos[loc_nr];
@@ -338,7 +335,7 @@ void local_bitvector_analysist::build()
338335
{
339336
assert(succ<loc_infos.size());
340337
if(merge(loc_infos[succ], (loc_info_dest)))
341-
work_queue.push(succ);
338+
work_queue.insert(succ);
342339
}
343340
}
344341
}
@@ -348,7 +345,7 @@ void local_bitvector_analysist::output(
348345
const goto_functiont &goto_function,
349346
const namespacet &ns) const
350347
{
351-
unsigned l=0;
348+
std::size_t l = 0;
352349

353350
for(const auto &instruction : goto_function.body.instructions)
354351
{

src/analyses/local_bitvector_analysis.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ Author: Daniel Kroening, [email protected]
1212
#ifndef CPROVER_ANALYSES_LOCAL_BITVECTOR_ANALYSIS_H
1313
#define CPROVER_ANALYSES_LOCAL_BITVECTOR_ANALYSIS_H
1414

15-
#include <stack>
16-
1715
#include <util/expanding_vector.h>
1816
#include <util/numbering.h>
1917

@@ -182,8 +180,6 @@ class local_bitvector_analysist
182180
const namespacet &ns;
183181
void build();
184182

185-
typedef std::stack<unsigned> work_queuet;
186-
187183
numberingt<irep_idt> pointers;
188184

189185
// pointers -> flagst

0 commit comments

Comments
 (0)