Handle non returning intrinsics#736
Merged
adpaco-aws merged 5 commits intomodel-checking:mainfrom Jan 11, 2022
Merged
Conversation
5d128eb to
5079c97
Compare
celinval
reviewed
Jan 7, 2022
| let loc = self.codegen_span_option(span); | ||
| debug!("codegen_nonret_intrinsic:\n\tinstance {:?}\n\tspan {:?}", instance, span); | ||
| match intrinsic { | ||
| "abort" => Stmt::assert_false("reached intrinsic::abort", loc), |
Contributor
There was a problem hiding this comment.
I recommend using GotocCtx::codegen_fatal_error() here. The Stmt::assert_false will not abort the program execution path.
celinval
reviewed
Jan 7, 2022
|
|
||
| /// Handles codegen for non returning intrinsics | ||
| /// Non returning intrinsics are not associated with a destination | ||
| pub fn codegen_nonret_intrinsic( |
Contributor
There was a problem hiding this comment.
nit: I would rename it to codegen_never_return_intrinsic()
celinval
suggested changes
Jan 7, 2022
Contributor
celinval
left a comment
There was a problem hiding this comment.
It looks good. We do need to add either an assume(false) or abort() call after the assert(false) though. In gotoc, an assertion failure does not interrupt the execution flow which may cause some odd behavior.
Contributor
Author
|
Thanks @celinval ! Renamed and replaced |
Closed
tedinski
pushed a commit
to tedinski/rmc
that referenced
this pull request
Apr 26, 2022
* Handle non returning intrinsics * Newline in comment * Address comments
tedinski
pushed a commit
that referenced
this pull request
Apr 27, 2022
* Handle non returning intrinsics * Newline in comment * Address comments
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.
Description of changes:
Adds a specific function for handling of non returning intrinsics, which currently are
abortand a special case oftransmute.Resolved issues:
Resolves #734
Call-outs:
Wrote a function for these special intrinsics but they can also be handled within the
codegen_intrinsicfunction. That would require passingpas an option (i.e., not unwrap before call tocodegen_intrinsic) and match on it at the beginning ofcodegen_intrinsic. Let me know if you prefer it that way.Testing:
How is this change tested? Existing regression + new test for transmute.
Is this a refactor change? No.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.