Add verifier::shadow_data#2561
Draft
Chris-Hawblitzel wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds tracking of shadow data associated with exec function parameters, return values, and local variables. This is useful when the SMT encoding of these values omits some data that is irrelevant to ordinary Verus verification but that may be useful to lower-level code. In particular, while the SMT encoding of a shared reference
&tis just the SMT encoding oft, with no underlying pointer information, the shadow data for a&tparameter, return value, or local variable can contain the extra pointer information.To opt into this feature, a function uses the attribute
#[verifier::shadow_data]. This creates extra shadow variables in the SST/AIR/SMT representation of that function. Non-shadow_datafunctions that callshadow_datafunctions pass in uninterpreted shadow data for parameters and ignore shadow data for return values. Likewise, when ashadow_datafunction calls a non-shadow_datafunction, the parameter shadow data is ignored and the return shadow data is uninterpreted.In general, each parameter, return value, and local variable
xof typetgets shadow datashadow_data(x)of the entirely abstract typeShadowData<t>. For example:The shadow data feature is independent of any particular types -- it is not specialized in any way to
&ttypes. To use shadow data to get pointer information in&ttypes, you can declare an uninterp spec function that extracts pointer information from the typeShadowData<&T>for allT.You can just as easily have shadow data for values of types other than
&t, likeOption<&t>or(&t, &t). To use shadow data inside an Option, for example, you could do the following:The implementation of shadow data builds on #2560 , using extra SST parameters and return values to represent the shadow data values. For now, the
call_requiresandcall_ensuresaxioms are disabled for any functions marked#[verifier::shadow_data]. Within a function, tracking of shadow data is currently very conservative: direct local variable assignment, function call arguments, and function call return values are tracked precisely, but all other operations generate uninterpreted shadow data.By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.