Skip to content

Remove implementation for the unreachable intrinsic#1100

Merged
adpaco-aws merged 3 commits intomodel-checking:mainfrom
adpaco-aws:unreachable-audit
Apr 25, 2022
Merged

Remove implementation for the unreachable intrinsic#1100
adpaco-aws merged 3 commits intomodel-checking:mainfrom
adpaco-aws:unreachable-audit

Conversation

@adpaco-aws
Copy link
Contributor

Description of changes:

The implementation we had for the unreachable intrinsic is unreachable itself. The code being executed is actually the TerminatorKind::Unreachable, which generates an assert-false statement with the message "unreachable code".

Adding a test to ensure this keeps happening.

Resolved issues:

Part of #727

Call-outs:

Testing:

  • How is this change tested? Adds one test.

  • Is this a refactor change? No.

Checklist

  • Each commit message has a non-empty body, explaining why the change was made
  • Methods or procedures are documented
  • Regression or unit tests are included, or existing tests cover the modified code
  • My PR is restricted to a single feature or bugfix

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

@adpaco-aws adpaco-aws requested a review from a team as a code owner April 23, 2022 19:32
@@ -0,0 +1,2 @@
FAILURE\
"unreachable code" No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

newline?

Copy link
Contributor

@tedinski tedinski left a comment

Choose a reason for hiding this comment

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

Nice catch

@adpaco-aws adpaco-aws merged commit ccc1479 into model-checking:main Apr 25, 2022
}
"unchecked_sub" => codegen_op_with_overflow_check!(sub_overflow),
"unlikely" => self.codegen_expr_to_place(p, fargs.remove(0)),
"unreachable" => self.codegen_assert(
Copy link
Contributor

Choose a reason for hiding this comment

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

Since unreachable should be unreachable, I suggest making this more explicit:

"unreachable" => unreachable!("Expecting unreachable intrinsic to be handled using Terminator::Unreachable")

because just removing it gives the impression that it is not yet implemented (gets included in the _ bucket at the end of match statement).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will add this in a follow-up PR.

tedinski pushed a commit that referenced this pull request Apr 27, 2022
* Remove `unreachable` from intrinsics

* Add test for uses of `unreachable`
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.

4 participants