-
Notifications
You must be signed in to change notification settings - Fork 277
Introduce value-set supported simplifier for goto-symex #8642
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
base: develop
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8642 +/- ##
===========================================
+ Coverage 80.37% 80.39% +0.01%
===========================================
Files 1686 1688 +2
Lines 206889 206972 +83
Branches 73 73
===========================================
+ Hits 166289 166388 +99
+ Misses 40600 40584 -16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
b1e951c
to
fc80921
Compare
Move `try_evaluate_pointer_comparison` to a simplifier that can eventually support more cases than just equalities in GOTO conditions. The initial change does not alter behaviour (except that previously `try_evaluate_pointer_comparison` was even used when simplification was disabled). A side-effect is that we can also clean up renamedt.
value-set based simplifications may be helpful well outside just GOTO conditions.
When all candidates in the value set have the same offset we can replace a pointer_offset expression by the offset value found in the value set.
The value set can help us infer that, e.g., a particular pointer cannot be among the ones assigned to __CPROVER_dead_object, whereby we can simplify R_OK/W_OK expressions.
ac731d4
to
77d0e0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any meaningful comment on the simplification at the symbolic execution level and all the changes LGTM. It's mostly creating simplify_expr_with_value_set
with additional clean ups and maintaining the behaviour.
simplify_exprt::resultt<> | ||
simplify_expr_with_value_sett::simplify_pointer_offset( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd include a header comment here with your commit description
When all candidates in the value set have the same offset we can replace
a pointer_offset expression by the offset value found in the value set.
Since there is only one simplification applied. This is nitpick since one may infer from the code.
/// Try to evaluate pointer comparisons where they can be trivially determined | ||
/// using the value-set. This is optional as all it does is allow symex to | ||
/// resolve some comparisons itself and therefore create a simpler formula for | ||
/// the SAT solver. | ||
/// \param [in,out] condition: An L2-renamed expression with boolean type | ||
/// \param value_set: The value-set for determining what pointer-typed symbols | ||
/// might possibly point to | ||
/// \param language_mode: The language mode | ||
/// \param ns: A namespace | ||
/// \return The possibly modified condition | ||
renamedt<exprt, L2> try_evaluate_pointer_comparisons( | ||
renamedt<exprt, L2> condition, | ||
const value_sett &value_set, | ||
const irep_idt &language_mode, | ||
const namespacet &ns); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: it'd be nice if the clean up was done on a separate commit.
// all pointed-to objects on the left-hand side are different from any of | ||
// the pointed-to objects on the right-hand side | ||
return expr.id() == ID_equal ? changed(static_cast<exprt>(false_exprt{})) | ||
: changed(static_cast<exprt>(true_exprt{})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If pointed-to objects are the same for LHS and RHS but for each object we have statically different symbolic offsets then we could conclude that the comparison is still always false ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to say this still seems to rely only on object information, not really using offset info to the fullest ? but this might already be done somewhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The simplifier class could be improved with some more doc explaining how knowledge of the symbolic offsets for pointers are used to simplify pointer comparisons
Move
try_evaluate_pointer_comparison
to a simplifier that can eventually support more cases than just equalities in GOTO conditions. The initial change does not alter behaviour (except that previouslytry_evaluate_pointer_comparison
was even used when simplification was disabled).A side-effect is that we can also clean up renamedt.