-
Notifications
You must be signed in to change notification settings - Fork 277
Simplify multiple-of-element size access to arrays #8627
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 #8627 +/- ##
=========================================
Coverage 80.37% 80.38%
=========================================
Files 1686 1686
Lines 206885 207022 +137
Branches 73 73
=========================================
+ Hits 166276 166405 +129
- Misses 40609 40617 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Is there a way to share some of the pattern matching conditions between the array-read and array-write cases ? |
Seems like we should also be able to pattern match an access to a member of a struct in an array of structs like a[i].m, the offset would be of the form i*sizeof(T) + offset(T,m) and turn that into a functional update as well ? |
959a535
to
0307a14
Compare
Done. |
0307a14
to
ba35ebf
Compare
ba35ebf
to
65d33b4
Compare
The test will otherwise exhibit undefined behaviour under CBMC 6 settings (where malloc may fail). This, in turn, can cause the expected patterns not to show up in the trace.
Although the tests produce correct verification results, the encoding can be very large as shown in diffblue#8617.
Array operations may fall back to byte_extract or byte_update expressions in parts of the code base. Simplify this to index or WITH expressions, respectively, when the offset is known to be a multiple of the array-element size, or a constant offset plus a multiple of the array-element size. Fixes: diffblue#8617
65d33b4
to
5c0408c
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.
From my understanding of the code the cases where we have a symbolic offset value with some shape that does not properly align with the underlying type of the accessed object seem to be handled, but could we add some negative tests for that ?
i.e. tests that check that the array access or array update still reduce to byte-level operations when they are supposed to ?
Also I just thought of the case you mentioned is frequent in the linux kernel, where people access struct fields using a base_pointer
+ offsetof(T, field)
, or accessing some array from its end pointer with a negative offset, which I don't think are handled.
Array operations may fall back to byte_extract or byte_update expressions in parts of the code base. Simplify this to index or WITH expressions, respectively, when the offset is known to be a multiple of the array-element size.