-
Notifications
You must be signed in to change notification settings - Fork 284
VSD - correct widening merge to handle extreme values #6190
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3756bae
widening interval_abstract_value upper_bound can hit maximum
jezhiggins 9bfa965
widening interval_abstract_value lower_bound can be minimum
jezhiggins 5efbdcd
Gather interval widening out into a little helper class of its own
jezhiggins 5cd42eb
Use widening_range in value_set_abstract_object widening merge
jezhiggins 9815a7b
Correct widening overflow detection for unsigned types
jezhiggins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /*******************************************************************\ | ||
|
|
||
| Module: helper for extending intervals during widening merges | ||
|
|
||
| Author: Jez Higgins | ||
|
|
||
| \*******************************************************************/ | ||
|
|
||
| #include "widened_range.h" | ||
| #include <util/simplify_expr.h> | ||
|
|
||
| static bool has_underflowed(const exprt &value) | ||
| { | ||
| return constant_interval_exprt::greater_than( | ||
| value, from_integer(0, value.type())); | ||
| } | ||
| static bool has_overflowed(const exprt &value, const exprt &initial_value) | ||
| { | ||
| return constant_interval_exprt::less_than(value, initial_value); | ||
| } | ||
|
|
||
| exprt widened_ranget::widen_lower_bound() const | ||
| { | ||
| if(!is_lower_widened) | ||
| return lower_bound; | ||
|
|
||
| auto new_lower_bound = simplify_expr(minus_exprt(lower_bound, range_), ns_); | ||
|
|
||
| if( | ||
| constant_interval_exprt::contains_extreme(new_lower_bound) || | ||
| has_underflowed(new_lower_bound)) | ||
| return min_exprt(lower_bound.type()); | ||
|
|
||
| return new_lower_bound; | ||
| } | ||
|
|
||
| exprt widened_ranget::widen_upper_bound() const | ||
| { | ||
| if(!is_upper_widened) | ||
| return upper_bound; | ||
|
|
||
| auto new_upper_bound = simplify_expr(plus_exprt(upper_bound, range_), ns_); | ||
|
|
||
| if( | ||
| constant_interval_exprt::contains_extreme(new_upper_bound) || | ||
| has_overflowed(new_upper_bound, upper_bound)) | ||
| return max_exprt(upper_bound.type()); | ||
|
|
||
| return new_upper_bound; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /*******************************************************************\ | ||
|
|
||
| Module: helper for extending intervals during widening merges | ||
|
|
||
| Author: Jez Higgins | ||
|
|
||
| \*******************************************************************/ | ||
|
|
||
| #ifndef CPROVER_ANALYSES_VARIABLE_SENSITIVITY_WIDENED_RANGE_H | ||
| #define CPROVER_ANALYSES_VARIABLE_SENSITIVITY_WIDENED_RANGE_H | ||
|
|
||
| #include <util/arith_tools.h> | ||
| #include <util/interval.h> | ||
| #include <util/namespace.h> | ||
| #include <util/symbol_table.h> | ||
|
|
||
| class widened_ranget | ||
| { | ||
| public: | ||
| widened_ranget( | ||
| const constant_interval_exprt &lhs, | ||
| const constant_interval_exprt &rhs) | ||
| : is_lower_widened( | ||
| constant_interval_exprt::less_than(rhs.get_lower(), lhs.get_lower())), | ||
| is_upper_widened( | ||
| constant_interval_exprt::less_than(lhs.get_upper(), rhs.get_upper())), | ||
| lower_bound( | ||
| constant_interval_exprt::get_min(lhs.get_lower(), rhs.get_lower())), | ||
| upper_bound( | ||
| constant_interval_exprt::get_max(lhs.get_upper(), rhs.get_upper())), | ||
| ns_(symbol_tablet{}), | ||
| range_(plus_exprt( | ||
| minus_exprt(upper_bound, lower_bound), | ||
| from_integer(1, lhs.type()))), | ||
| widened_lower_bound(widen_lower_bound()), | ||
| widened_upper_bound(widen_upper_bound()) | ||
| { | ||
| } | ||
|
|
||
| const bool is_lower_widened; | ||
| const bool is_upper_widened; | ||
| const exprt lower_bound; | ||
| const exprt upper_bound; | ||
|
|
||
| private: | ||
| namespacet ns_; | ||
| exprt range_; | ||
|
|
||
| public: | ||
| const exprt widened_lower_bound; | ||
| const exprt widened_upper_bound; | ||
|
|
||
| private: | ||
| exprt widen_lower_bound() const; | ||
| exprt widen_upper_bound() const; | ||
| }; | ||
|
|
||
| #endif // CPROVER_ANALYSES_VARIABLE_SENSITIVITY_WIDENED_RANGE_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.