Skip to content

Commit 63f3a8d

Browse files
committed
Value sets: make pointers nondet only once
When `get_value_set_rec` discovers a nondet symbol it will consider the pointer pointing to any of the known objects (as of 3789670). It suffices to do this once for each run of `get_value_set`, even when multiple nondet symbols are encountered while traversing an expression. This reduces the symex time on the test of #7357 from 930 seconds to 404 seconds.
1 parent 0834274 commit 63f3a8d

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

src/pointer-analysis/value_set.cpp

+19-11
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,24 @@ value_sett::object_mapt value_sett::get_value_set(
371371

372372
object_mapt dest;
373373
get_value_set_rec(expr, dest, "", expr.type(), ns);
374+
375+
if(nondet_pointer && expr.type().id() == ID_pointer)
376+
{
377+
// we'll take the union of all objects we see, with unspecified offsets
378+
values.iterate([this, &dest](const irep_idt &key, const entryt &value) {
379+
for(const auto &object : value.object_map.read())
380+
insert(dest, object.first, offsett());
381+
});
382+
383+
// we'll add null, in case it's not there yet
384+
insert(
385+
dest,
386+
exprt(ID_null_object, to_pointer_type(expr.type()).base_type()),
387+
offsett());
388+
389+
nondet_pointer = false;
390+
}
391+
374392
return dest;
375393
}
376394

@@ -512,17 +530,7 @@ void value_sett::get_value_set_rec(
512530
{
513531
if(expr.type().id() == ID_pointer)
514532
{
515-
// we'll take the union of all objects we see, with unspecified offsets
516-
values.iterate([this, &dest](const irep_idt &key, const entryt &value) {
517-
for(const auto &object : value.object_map.read())
518-
insert(dest, object.first, offsett());
519-
});
520-
521-
// we'll add null, in case it's not there yet
522-
insert(
523-
dest,
524-
exprt(ID_null_object, to_pointer_type(expr_type).base_type()),
525-
offsett());
533+
nondet_pointer = true;
526534
}
527535
else
528536
insert(dest, exprt(ID_unknown, original_type));

src/pointer-analysis/value_set.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,9 @@ class value_sett
494494
const codet &code,
495495
const namespacet &ns);
496496

497-
private:
497+
mutable bool nondet_pointer = false;
498+
499+
private:
498500
/// Subclass customisation point to filter or otherwise alter the value-set
499501
/// returned from get_value_set before it is passed into assign. For example,
500502
/// this is used in one subclass to tag and thus differentiate values that

0 commit comments

Comments
 (0)