Skip to content

Vsd - widening during abstract object merge #6046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jun 16, 2021

Conversation

jezhiggins
Copy link
Contributor

@jezhiggins jezhiggins commented Apr 22, 2021

Implements widening during abstract object merges.

Widening during a merge is determined by the trace_ptrt locations passed into variable_sensitivity_domaint::merge. When widening should occur hasn't been changed, what this PR does is actually try and widen when requested.

If a merge result is unmodified, no widening will take place.

Constants don't need to be widened - rather, they already do because they go TOP.

For intervals, we consider which bound is being extended by the merge then extend that further out by the width of the interval. Eg.

  • normal merge of [1, 3] with 4 results in [1, 4]
  • widening merge of [1,3] with 4 results in [1, 8].
    • The merge result [1, 4] has been extended on the upper bound (4 > 3).
    • The interval width is also 4, so the new upper bound is 4 + 4, hence [1, 8]
  • widening merge of [4, 5] with -1 results in [-4, 5]
    • The merge result [1, 5] has been extended on the lower bound (1 < 4).
    • The interval width is 5, so the new lower bound is 1 - 5, hence [-4, 5].
      If the merge extends both upper and lower bounds, we extend at both ends.

For value-sets, a similar mechanism is applied. If the upper or lower value in the set has changed in the merge, we extend that further, either by replacing a constant value with an interval or by extending the interval. Eg.

  • merging { 1, 3 } with 4 gives { 1, 3, 4 }
  • widening merge of { 1, 3 } with 4 results in { 1, 3, [4, 8] }

This PR also includes value-set compacting. When a value-set becomes large, that is has more than value_set_abstract_objectt::max_value_set_size elements, it is compacted. This has two stages

  • non-destructive compacting - if the set contains any intervals, combine overlapping intervals together and then discard any values contained in those intervals
    • compacting { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, [5, 12] } would give { 1, 2, 3, 4, [5, 12] }
    • compacting { 1, 2, 3, 4, 5, 7, 8, [5, 10], [8, 12] } would give { 1, 2, 3, 4, [5, 12] }
    • compacting { [1, 4], 1, 2, 4, 5, 6, 7, [8, 10], [6, 12] } would give { [1, 4], 5, [6, 12] }
      If the value-set is still too large, we move to the second stage
  • destructive compacting - creating new intervals in value-set, then reapplying the non-destructive compact.
    • the intervals span the lower and upper third of the set's range
    • so { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 } would become { [1, 4], 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, [9, 12] }, which would compact to { [1, 4], 5, 6, 7, 8, [9, 12] }.
    • if value set is still too large (because of outlier values), split the value-set into two intervals spanning the lower and upper half of the range.

@jezhiggins jezhiggins force-pushed the vsd-widening-in-merge branch from a5477ee to d18bd36 Compare April 22, 2021 14:36
@codecov
Copy link

codecov bot commented Apr 22, 2021

Codecov Report

Merging #6046 (48146e0) into develop (0002950) will increase coverage by 7.94%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #6046      +/-   ##
===========================================
+ Coverage    67.40%   75.35%   +7.94%     
===========================================
  Files         1157     1454     +297     
  Lines        95236   160914   +65678     
===========================================
+ Hits         64197   121253   +57056     
- Misses       31039    39661    +8622     
Flag Coverage Δ
cproversmt2 ?
regression ?
unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/util/string_container.cpp 52.94% <0.00%> (-47.06%) ⬇️
src/solvers/prop/prop.cpp 42.85% <0.00%> (-41.76%) ⬇️
src/solvers/flattening/boolbv_member.cpp 53.65% <0.00%> (-38.65%) ⬇️
src/cpp/cpp_storage_spec.cpp 65.00% <0.00%> (-35.00%) ⬇️
src/util/cmdline.h 66.66% <0.00%> (-33.34%) ⬇️
src/solvers/strings/array_pool.h 66.66% <0.00%> (-33.34%) ⬇️
src/solvers/strings/string_refinement.h 66.66% <0.00%> (-33.34%) ⬇️
...rs/strings/string_concatenation_builtin_function.h 0.00% <0.00%> (-33.34%) ⬇️
src/cbmc/c_test_input_generator.cpp 60.00% <0.00%> (-30.33%) ⬇️
src/ansi-c/c_typecheck_base.cpp 55.76% <0.00%> (-25.13%) ⬇️
... and 1433 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f847fcd...48146e0. Read the comment docs.

@jezhiggins jezhiggins force-pushed the vsd-widening-in-merge branch 6 times, most recently from 713d2c1 to 7ec0228 Compare April 26, 2021 12:49
@jezhiggins jezhiggins force-pushed the vsd-widening-in-merge branch 15 times, most recently from f910b7b to 37622eb Compare May 6, 2021 09:14
@jezhiggins jezhiggins force-pushed the vsd-widening-in-merge branch 4 times, most recently from 8152899 to b308015 Compare May 8, 2021 11:57
@jezhiggins jezhiggins force-pushed the vsd-widening-in-merge branch 2 times, most recently from 75fad1f to 0308353 Compare May 11, 2021 08:47
@jezhiggins jezhiggins force-pushed the vsd-widening-in-merge branch from fca209a to 6609a73 Compare June 12, 2021 12:14
Eliminate boolean by-ref out parameter, instead returning a simple
struct holding the merged object, and the modified flag.
It has been made redundant by the VSD changes over the past few months,
and its continued presence is simply now confusing.
Consequently we can remove value_set_abstract_objectt::write and
value_set_*::resolve_new_values.

Added UNREACHABLE assertion in abstract_value_objectt::write should this
every change (deliverately or otherwise).
No longer convert large value sets into an interval.
Also should_widen to could_widen - it's a request not an instruction
Extends upper and/or lower bound by the width of the interval.

Does not widen in lhs value would be unchanged in non-widening merge -
ie only widens if interval is extended by the merge.
Stripped out conversion to interval. Trying to get a little more
sophisticated in our compaction.
If the size of the set is large, if there are any intervals in the set,
try merging values into them.
Generate two intervals covering the upper and lower part of the value
sets range of values, then merge values into those.
If added intervals don't reduce the size of the set, widen intervals
towards the middle of the range, and repeat.
If the range of the merged value_set is no wider than the original
object, no widening takes place. Otherwise, both the upper and lower
boundary value can be extended, if the merged-in value extends in that
direction.
Only collapse constants or intervals which overlap the extended upper or
lower bound. Don't perform a general compact, unless the set has become
large.
@jezhiggins jezhiggins force-pushed the vsd-widening-in-merge branch from 6609a73 to 743b047 Compare June 15, 2021 13:52
@jezhiggins jezhiggins marked this pull request as ready for review June 15, 2021 15:22
Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the PR is large, it seems the changes are mostly pretty straight-forward and a lot of it is tracing the extra parameter to merge through the various interfaces.

Simple variable, array element, and field in a structure. They all
compact.
@jezhiggins jezhiggins force-pushed the vsd-widening-in-merge branch from 743b047 to 48146e0 Compare June 16, 2021 15:16
@martin-cs martin-cs merged commit abd4412 into diffblue:develop Jun 16, 2021
@jezhiggins jezhiggins deleted the vsd-widening-in-merge branch June 16, 2021 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants