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

[SILGen] Emit block after unreachable when emitting if/switch expressions #66551

Merged
merged 1 commit into from
Jun 12, 2023

Conversation

hamishknight
Copy link
Collaborator

@hamishknight hamishknight commented Jun 12, 2023

When emitting the underlying switch statement for a switch expression, we emit an unreachable if the subject is uninhabited. Statement emission code can handle this, but expression emission expects an RValue to handed back. To remedy this, emit an unreachable block that we can emit the rest of the expression emission code into. The SILOptimizer will then drop this unreachable block.

Resolves #66490
rdar://110636210

…ions

When emitting the underlying `switch` statement
for a `switch` expression, we emit an `unreachable`
if the subject is uninhabited. Statement emission
code can handle this, but expression emission expects
an RValue to handed back. To remedy this, emit
an unreachable block that we can emit the rest of
the expression emission code into. The SILOptimizer
will then drop this unreachable block.
@hamishknight
Copy link
Collaborator Author

@swift-ci please test

Copy link
Member

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm

@hamishknight
Copy link
Collaborator Author

@swift-ci please test Windows

@hamishknight hamishknight merged commit ae2287d into apple:main Jun 12, 2023
5 checks passed
@hamishknight hamishknight deleted the never-say-never branch June 12, 2023 18:27
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.

Assigning to self in a Never initializer using a switch expression crashes the compiler
2 participants