Skip to content

Byte-operator lowering: Add support for byte-extracting unions #4717

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 1 commit into from
Nov 9, 2022

Conversation

tautschnig
Copy link
Collaborator

@tautschnig tautschnig commented May 28, 2019

We already had support for structs, arrays, vectors in place; add unions
following the same approach. This is required for some SV-COMP device
driver benchmarks, including
ldv-linux-3.16-rc1/43_2a_consumption_linux-3.16-rc1.tar.xz-43_2a-drivers--scsi--qla2xxx--tcm_qla2xxx.ko-entry_point.cil.out.i

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: 9384d50).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/113362951

@smowton
Copy link
Contributor

smowton commented May 28, 2019

Also tests please, including one with multiple like-sized components (e.g. union { double d; uint64_t ul; })

@tautschnig tautschnig force-pushed the byte-operator-union branch from 9384d50 to 7bae4d5 Compare May 29, 2019 17:39
@tautschnig
Copy link
Collaborator Author

Also tests please, including one with multiple like-sized components (e.g. union { double d; uint64_t ul; })

Test added, but note that this code will only be reached when none of the members as a known non-zero size.

@tautschnig tautschnig self-assigned this May 29, 2019
Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

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

Hmm, are you really sure we want to do lifting to the first component if it's the wrong size, rather than just abandoning conversion and doing whatever we did before this code existed?

@tautschnig
Copy link
Collaborator Author

Hmm, are you really sure we want to do lifting to the first component if it's the wrong size, rather than just abandoning conversion and doing whatever we did before this code existed?

No, I'm not sure :-) - but what we did before this code existed is running into a failing invariant that said that this case is unsupported.

@smowton
Copy link
Contributor

smowton commented May 30, 2019

Perhaps it would be better to have an invariant that if we're trying to turn a bv[N] into a union { T1 e1; T2 e2; ... } then at least one of T1 ... Tn has the correct size, then we'll know when this code is doing something nonsensical and can address that particular case?

@codecov
Copy link

codecov bot commented Dec 27, 2020

Codecov Report

Base: 78.26% // Head: 78.26% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (7032a1f) compared to base (557624c).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4717   +/-   ##
========================================
  Coverage    78.26%   78.26%           
========================================
  Files         1642     1642           
  Lines       189830   189834    +4     
========================================
+ Hits        148568   148575    +7     
+ Misses       41262    41259    -3     
Impacted Files Coverage Δ
src/solvers/lowering/byte_operators.cpp 92.76% <100.00%> (+0.02%) ⬆️
src/solvers/flattening/boolbv.cpp 87.46% <0.00%> (+0.29%) ⬆️
src/solvers/flattening/arrays.cpp 80.37% <0.00%> (+0.53%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

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.

Approve but please do have a look at the comments.

@tautschnig tautschnig force-pushed the byte-operator-union branch 3 times, most recently from da4866c to 97fbe27 Compare November 8, 2022 11:50
The test included made apparent that we weren't yet handling unbounded
byte extracts (out of a bounded object) for unions, which just fell back
to unpacking an empty array.
@tautschnig tautschnig merged commit 70b7cf7 into diffblue:develop Nov 9, 2022
@tautschnig tautschnig deleted the byte-operator-union branch November 9, 2022 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants