Skip to content
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

[Boogie Backend] Codegen the arguments to Kani intrinsics inside the functions that handle the intrinsics #2924

Merged

Conversation

zhassan-aws
Copy link
Contributor

This is a refactor change: currently, the functions that codegen Kani intrinsics (asserts, assumes, etc.) take the arguments to the intrinsics as Boogie expressions (boogie_ast::boogie_program::Expr). In other words, the MIR arguments (rustc_middle::mir::syntax::Operand) are converted to Boogie expressions before passing them to the functions.

This PR changes the functions to take the MIR arguments directly, and perform the codegen into Boogie expressions inside the functions. This allows those functions to query any information in the MIR Operand, that is not available after codegen to Boogie expressions.

Note: it may make sense to do the same change for the Goto backend to avoid having to pattern match on the expressions (e.g.

let msg = tcx.extract_const_message(&msg).unwrap();
), and instead get the information needed from the MIR operand directly.

Resolves #ISSUE-NUMBER

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@zhassan-aws zhassan-aws requested a review from a team as a code owner December 8, 2023 00:48
@zhassan-aws zhassan-aws merged commit dc78b84 into model-checking:features/boogie Dec 8, 2023
19 of 20 checks passed
@zhassan-aws zhassan-aws deleted the intrinsic-args branch December 8, 2023 01:16
zhassan-aws added a commit that referenced this pull request Dec 13, 2023
…ndle the intrinsics (#2924)

This is a refactor change: currently, the functions that codegen Kani
intrinsics (asserts, assumes, etc.) take the arguments to the intrinsics
as Boogie expressions (`boogie_ast::boogie_program::Expr`). In other
words, the MIR arguments (`rustc_middle::mir::syntax::Operand`) are
converted to Boogie expressions before passing them to the functions.

This PR changes the functions to take the MIR arguments directly, and
perform the codegen into Boogie expressions inside the functions. This
allows those functions to query any information in the MIR `Operand`,
that is not available after codegen to Boogie expressions.

Note: it may make sense to do the same change for the Goto backend to
avoid having to pattern match on the expressions (e.g.
https://github.com/model-checking/kani/blob/2aca488ba9d64d2aaeae3b7774acf367bea42be9/kani-compiler/src/codegen_cprover_gotoc/overrides/hooks.rs#L74),
and instead get the information needed from the MIR operand directly.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.
@zhassan-aws zhassan-aws changed the title Codegen the arguments to Kani intrinsics inside the functions that handle the intrinsics [Boogie Backend] Codegen the arguments to Kani intrinsics inside the functions that handle the intrinsics Dec 14, 2023
zhassan-aws added a commit that referenced this pull request Dec 15, 2023
…ndle the intrinsics (#2924)

This is a refactor change: currently, the functions that codegen Kani
intrinsics (asserts, assumes, etc.) take the arguments to the intrinsics
as Boogie expressions (`boogie_ast::boogie_program::Expr`). In other
words, the MIR arguments (`rustc_middle::mir::syntax::Operand`) are
converted to Boogie expressions before passing them to the functions.

This PR changes the functions to take the MIR arguments directly, and
perform the codegen into Boogie expressions inside the functions. This
allows those functions to query any information in the MIR `Operand`,
that is not available after codegen to Boogie expressions.

Note: it may make sense to do the same change for the Goto backend to
avoid having to pattern match on the expressions (e.g.
https://github.com/model-checking/kani/blob/2aca488ba9d64d2aaeae3b7774acf367bea42be9/kani-compiler/src/codegen_cprover_gotoc/overrides/hooks.rs#L74),
and instead get the information needed from the MIR operand directly.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.
zhassan-aws added a commit that referenced this pull request Dec 19, 2023
…ndle the intrinsics (#2924)

This is a refactor change: currently, the functions that codegen Kani
intrinsics (asserts, assumes, etc.) take the arguments to the intrinsics
as Boogie expressions (`boogie_ast::boogie_program::Expr`). In other
words, the MIR arguments (`rustc_middle::mir::syntax::Operand`) are
converted to Boogie expressions before passing them to the functions.

This PR changes the functions to take the MIR arguments directly, and
perform the codegen into Boogie expressions inside the functions. This
allows those functions to query any information in the MIR `Operand`,
that is not available after codegen to Boogie expressions.

Note: it may make sense to do the same change for the Goto backend to
avoid having to pattern match on the expressions (e.g.
https://github.com/model-checking/kani/blob/2aca488ba9d64d2aaeae3b7774acf367bea42be9/kani-compiler/src/codegen_cprover_gotoc/overrides/hooks.rs#L74),
and instead get the information needed from the MIR operand directly.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant