-
Notifications
You must be signed in to change notification settings - Fork 160
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
Faster CBMC stubs for memset and memcpy #300
Conversation
510cf7a
to
6feed08
Compare
.cbmc-batch/jobs/memcpy_using_uint64/memcpy_using_uint64_harness.c
Outdated
Show resolved
Hide resolved
89dc5f7
to
7603890
Compare
uint64_t *d = (uint64_t *)dst; | ||
|
||
for (size_t i = 0; i < num_uint64s; ++i) { | ||
d[i] = 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.
Shouldn't this be d[i] = c;
or am I missing something?
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.
This harness is specialized for the common case of memset(0 ...)
. It uses 0
as the assignment here to let CBMC do more constant propagation. This is safe because of the assert here
assert(c == 0); |
Description of changes:
When CBMC processes a
memcpy
ormemset
, it ends up doing many invocations of the array theory, which is expensive. Instead, provide CBMC stubs which use 64 bit arithmetic, which in practice often proves to lead to quicker proofs.Each new implementation has a CBMC proof that it is functionally equivalent to a naive implementation.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.