Skip to content

Commit 38604cf

Browse files
committed
Local bitvector analysis: reduce number of node visits
By using a set instead of a stack as work queue we reduce the number of visits to each node in two ways: 1) The work queue will not contain duplicate nodes. 2) When dequeuing successor nodes, back edges will be given preference over forward ones. Once the later (in program order) node is visited, more information is already merged into the abstract state. On a goto function with 160822 instruction, this reduces processing time (just the local bitvector analysis) from 1700 seconds down to 72 seconds. The number of invocations of `local_bitvector_analysist::merge` previously was 32815499 (204 times the number of nodes), and is now 997083 (6 times the number of nodes).
1 parent eeddb3f commit 38604cf

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/analyses/local_bitvector_analysis.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ void local_bitvector_analysist::build()
242242
if(cfg.nodes.empty())
243243
return;
244244

245-
work_queuet work_queue;
246-
work_queue.push(0);
245+
std::set<unsigned> work_queue;
246+
work_queue.insert(0);
247247

248248
loc_infos.resize(cfg.nodes.size());
249249

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

259259
while(!work_queue.empty())
260260
{
261-
unsigned loc_nr=work_queue.top();
261+
unsigned loc_nr = *work_queue.begin();
262262
const local_cfgt::nodet &node=cfg.nodes[loc_nr];
263263
const goto_programt::instructiont &instruction=*node.t;
264-
work_queue.pop();
264+
work_queue.erase(work_queue.begin());
265265

266266
auto &loc_info_src=loc_infos[loc_nr];
267267
auto loc_info_dest=loc_infos[loc_nr];
@@ -338,7 +338,7 @@ void local_bitvector_analysist::build()
338338
{
339339
assert(succ<loc_infos.size());
340340
if(merge(loc_infos[succ], (loc_info_dest)))
341-
work_queue.push(succ);
341+
work_queue.insert(succ);
342342
}
343343
}
344344
}

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)