-
Notifications
You must be signed in to change notification settings - Fork 274
Byte-update lowering: handle sub-byte sized bit fields #5390
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
Byte-update lowering: handle sub-byte sized bit fields #5390
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #5390 +/- ##
========================================
Coverage 68.52% 68.52%
========================================
Files 1187 1187
Lines 98265 98271 +6
========================================
+ Hits 67339 67345 +6
Misses 30926 30926
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@@ -2136,10 +2136,30 @@ static exprt lower_byte_update( | |||
instantiate_byte_array(value_as_byte_array, 0, (type_bits + 7) / 8, ns); | |||
} | |||
|
|||
const std::size_t update_size = update_bytes.size(); |
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.
While we're here: recommend always using unit suffixes in this code (update_size_bytes, width_bits)
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.
Done.
@@ -0,0 +1,8 @@ | |||
CORE |
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.
Tests: can we test behaviour in the other endianness somehow?
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.
Setting the --arch
flags appropriately should do it.
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 think endianness actually matters in this test?
if(b.dummy <= sizeof(struct blob)) | ||
memset(&b, 0, b.dummy); | ||
|
||
assert(b1.dummy != sizeof(struct blob) || b.bit == 0); |
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.
Brutal! If you are need to change things in this PR, please could you add a comment or two here to explain what you are testing because I fear that people without your knowledge of C struct packing rules and how they relate to bit-fields might miss some of the subtlety here.
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.
Done.
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.
Looks good.
@@ -0,0 +1,8 @@ | |||
CORE |
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.
Setting the --arch
flags appropriately should do it.
@tautschnig can we merge this PR and close #5389? |
Extend the value to be updated to the update size immediately to avoid extractbits operations that attempt to extract bits that do not exist. Fixes: diffblue#5389
Use variable names that immediately clarify that widths are measured in bits.
54411e0
to
e16b7db
Compare
Extend the value to be updated to the update size immediately to avoid
extractbits operations that attempt to extract bits that do not exist.
Fixes: #5389